HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   HOWTO-Related Questions (http://www.howtoforge.com/forums/forumdisplay.php?f=2)
-   -   PHP upgrade from PHP4 to PHP5 (http://www.howtoforge.com/forums/showthread.php?t=58931)

zm1128 2nd October 2012 03:17

PHP upgrade from PHP4 to PHP5
 
Hello, I am very new to coding, and need to convert the following script from PHP4 to PHP5. Can anyone please help in telling me what parts I need to change?

Thank you.

**********
<?php
$error=false;
if($_POST['posFName']!=null and $_POST['posLName']!=null and $_POST['posTitle']!=null and $_POST['posCompany']!=null and $_POST['posadd1']!=null and $_POST
['poscity']!=null and $_POST['posState']!=null and $_POST['poszip']!=null and $_POST['posEmail']!=null and $_POST['posphone']!=null and $_POST['stage']!=null){
require_once("PHPMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$email="js@mail.com"; // Recipients email ID
$name="John Smith"; // Recipient's name
$mail->From = "webform@email.com";
$mail->FromName = "My Company";
$mail->AddAddress($email,$name);
$mail->AddAddress("jjs@mail.com","Jack Smith");
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Live Demo Request Information";
$mail->Body = "<p>You have a new mail from Live Demo Section.<br/><br/>First Name : ".$_POST['posFName']."<br />Last Name : ".$_POST['posLName']." <br />Title : ".
$_POST['posTitle']."<br />Company : ".$_POST['posCompany']."<br />Address 1 : ".$_POST['posadd1']."<br />Address 2 : ".$_POST['posadd2']."<br />City : ".$_POST
['poscity']."<br />State : ".$_POST['posState']."<br />Email : ".$_POST['posEmail']."<br />Telephone - direct : ".$_POST['posphone']."<br />Please indicate the stage
of your initiative : ".$_POST['stage']; //HTML Body
$mail->AltBody = "<p>You have a new mail from Live Demo Section.<br/><br/>First Name : ".$_POST['posFName']."<br />Last Name : ".$_POST['posLName']." <br />Title : ".
$_POST['posTitle']."<br />Company : ".$_POST['posCompany']."<br />Address 1 : ".$_POST['posadd1']."<br />Address 2 : ".$_POST['posadd2']."<br />City : ".$_POST
['poscity']."<br />State : ".$_POST['posState']."<br />Email : ".$_POST['posEmail']."<br />Telephone - direct : ".$_POST['posphone']."<br />Please indicate the stage
of your initiative : ".$_POST['stage']; //Text Body
$mail->Send();
}else{
$error=true;
}
?>


**************************

Ben 2nd October 2012 14:21

Did you have any specific problems? What are the error message?

If not testes so far, just do so.

If you like to proactively change your script to avoid known backwards incompatibility you could either google for e.g. "php4 to 5 compatibility" or directly visit the php docs:

http://www.php.net/manual/en/migration5.php
http://www.php.net/manual/en/migrati...compatible.php

Did you also check whether phpmailer is php5 ready as well?

falko 2nd October 2012 14:22

Have you tried running it on PHP5? If there are errors you will know what to change.

zm1128 2nd October 2012 16:24

Thanks Ben, basically the form doesn't send the email. I have a hosting plan on GoDaddy and when I called support, they told me that the reason it doesn't work is because my form was developed in PHP4 and needs to be upgraded to PHP5. I had someone else originally build this as I am not a programmer. I need to know what to change (syntax, I think) to have it be PHP5 compatible.

zm1128 2nd October 2012 16:25

Thanks Falko, I am not sure how to run it in PHP5.

I have a hosting plan on GoDaddy and when I called support, they told me that the reason it doesn't work is because my form was developed in PHP4 and needs to be upgraded to PHP5. I had someone else originally build this as I am not a programmer. I need to know what to change (syntax, I think) to have it be PHP5 compatible.

Ben 4th October 2012 10:29

Quote:

Originally Posted by zm1128 (Post 286189)
Thanks Falko, I am not sure how to run it in PHP5.

my suggestion would be to have a lamp / wamp whatsoever test system e.g. in a VM at home to test several things.
Thus you just need to ensure having a webserver with php5 and that gives you access to the logs.

With regards to the logs, do you have access to the webserver logs or can the godaddy support send them to you so we can have a look here?

You could also add the following lines to the begginning of your script (directly after <?) to force the display of all errors. But this won't help if you script is causing a fatal error as it does not come to execution.
PHP Code:

error_reporting(E_ALL);
ini_set('display_errors','On'); 


TiTex 7th October 2012 08:52

zm1128 maybe you are using an old version of the php mailer class (class.phpmailer.php) , try updating it from here http://code.google.com/a/apache-extras.org/p/phpmailer/

make sure to backup your old files first


All times are GMT +2. The time now is 09:59.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.