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="[email protected]"; // Recipients email ID $name="John Smith"; // Recipient's name $mail->From = "[email protected]"; $mail->FromName = "My Company"; $mail->AddAddress($email,$name); $mail->AddAddress("[email protected]","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; } ?> **************************
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/migration5.incompatible.php Did you also check whether phpmailer is php5 ready as well?
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.
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.
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: error_reporting(E_ALL); ini_set('display_errors','On');
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