PHP upgrade from PHP4 to PHP5

Discussion in 'HOWTO-Related Questions' started by zm1128, Oct 2, 2012.

  1. zm1128

    zm1128 New Member

    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;
    }
    ?>


    **************************
     
  2. Ben

    Ben ISPConfig Developer ISPConfig Developer

  3. falko

    falko Super Moderator ISPConfig Developer

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

    zm1128 New Member

    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.
     
  5. zm1128

    zm1128 New Member

    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.
     
  6. Ben

    Ben ISPConfig Developer ISPConfig Developer

    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');
     
  7. TiTex

    TiTex New Member

Share This Page