www.webdeveloper.com
Results 1 to 2 of 2

Thread: PHP code issue

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    1

    PHP code issue

    I have a contact form on a mobile website but I am getting the following error and I dont know why, can some please help me on this:

    Error: Parse error: syntax error, unexpected T_STRING in /homepages/22/d147356302/htdocs/wightmobile/contact.php on line 48

    Source Code below:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>Contact STORM&reg; Driving School</title>
    <meta name="description" content="Contact STORM&reg; driving school">
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1;" name="viewport" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="robots" content="index, follow" />
    <link rel="stylesheet" href="css/jquery.mobile-1.1.0.min.css" />
    <link rel=”shortcut icon” href="http://localhost:841/images/favicon.ico" mce_href="http://http://localhost:841/images/favicon.ico" />
    <link rel="stylesheet" href="css/stylesheet.css" />
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).bind("mobileinit", function() {
    // jQuery Mobile's Ajax navigation does not work in all cases (e.g.,
    // when navigating from a mobile to a non-mobile page, or when clicking "back"
    // after a form post), hence disabling it.
    $.mobile.ajaxEnabled = false;
    //$.mobile.touchOverflowEnabled = true;
    });
    </script>
    <script src="js/jquery.mobile-1.1.0.min.js"></script>
    </head>
    <body>
    <div data-role="page" data-theme="a" class="page">

    <!-- The 'logo' DIV below was added to the default markup -->
    <div class="logo"></div>
    <div id="holder">
    <div id="content" data-role="content" class="page">
    <div id="menu">
    <table width="100%" cellpadding="0" cellspacing="5" border="0">
    <tr>
    <td id="menuitem" width="75"><a href="/">Home</a></td>
    <td id="menuitem" width="75"><a href="/services.php">Services</a></td>
    <td id="menuitem" width="75"><a href="/area.php">Area</a></td>
    <td id="menuitem" width="75"><a href="/contact.php">Contact</a></td>
    </tr>
    </table>
    </div>
    <h1>Contact Us</h1>
    <p class="center"><img src="/images/submit_button.gif" /></p>
    <p class="center">All fields marked with a (*) are required</p>
    <?php
    if(isset($_POST['submit'])){

    /*
    * Get Form Values
    */

    $strName = htmlentities($_POST['name']);
    $strEmail = htmlentities($_POST['email']);
    $strTele = htmlentities($_POST['phone']);
    $strService = htmlentities($_POST['service']);
    $strComments = htmlentities($_POST['comments']);

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    ini_set("SMTP", "localhost");
    ini_set("smtp_port", "25");
    ini_set("sendmail_from", $strEmail);



    /*
    * Build the e-mail body
    */

    $strBody = "Hi," . "<br>" . "<br>";
    $strBody = $strBody . "This message has been sent from the contact us form on the Storm Driving mobile website: " . "<br>";
    $strBody = $strBody . "------------------------------------------------------------------------------------------" . "<br>";
    $strBody = $strBody . "From: " . $strName . "<br>";
    $strBody = $strBody . "Email Address: " . $strEmail . "<br>";
    $strBody = $strBody . "Tele No.:" . $strTele . "<br>";
    $strBody = $strBody . "Service Required:" . $strService . "<br>";
    $strBody = $strBody . "Comments: " . $strComments . "<br>";
    $strBody = $strBody . "------------------------------------------------------------------------------------------" . "\r\n";
    /*
    * Set headers, email address and subject and send mail
    */

    $strToEmail = "enquiries@stormdriving.com";
    $strSubject = "Sent from Contact Form on Mobile Website";
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
    $headers .= 'From: ' . $strName . ' <' . $strEmail . '>' . "\r\n";
    if(mail($strToEmail, $strSubject, $strBody, $headers)){
    echo "<p class='error'>An email has been successfully sent!</p>";
    } else {
    /* echo "E-mail failed please contact...";*/
    }
    }
    ?>
    <p>
    <form action="/contact.php" method="post" name="personal" id="personal" onSubmit="return validate()">
    <label for="name"><strong>Your Name:*</strong></label>
    <input id="name" name="name" class="ui-bar-a" style="width:300px" type="text" value="" />
    <label for="phone"><strong>Telephone Number:*</strong></label>
    <input id="phone" name="phone" id="phone" class="ui-bar-a" style="width:300px" type="text" value="" maxlength="25" />
    <label for="email"><strong>Email Address:*</strong></label>
    <input id="email" name="email" id="email" class="ui-bar-a" style="width:300px" type="text" value="" maxlength="100" />
    <label for="service"><strong>Service:*</strong></label>
    <select name="service" id="service">
    <option value="">--Please Select--</option>
    <option value="Manual Lessons">Manual Lessons</option>
    <option value="Automatic Lessions">Automatic Lessons</option>
    </select>
    <label for="comments"><strong>Comments:</strong></label>
    <textarea name="comments" id="comments" style="width:300px" rows="5"></textarea>
    <input type="submit" id="submit" name="submit" data-role="submit" value="Submit">
    </form>
    </p>
    </div>

    <script language="JavaScript">
    function validate(){
    if(document.getElementById("name").value == ""){
    alert("Please enter your name");
    document.getElementById("name").focus();
    return(false);
    }

    if(document.getElementById("phone").value == ""){
    alert("Please enter your telephone number");
    document.getElementById("phone").focus();
    return(false);
    }

    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(document.getElementById("email").value)) {
    alert("Please provide a valid email address");
    document.getElementById("email").focus();
    return(false);
    }

    if(document.getElementById("service").value == ""){
    alert("Please select the service you require from the drop down list");
    document.getElementById("service").focus();
    return(false);
    }

    return(true);
    }
    </script>

    <div class="social">
    <div class="social-bar-title">Connect With Us Now!</div>
    <a rel="external" href="tel:+441983861016"><img alt="Call us" src="images/call.png" /></a>
    <a rel="external" href="mailto:info@stormdriving.com"><img alt="Email" src="images/email.png" /></a>
    <a rel="external" href="http://www.facebook.com/pages/Guildford-United-Kingdom/Storm-Driving-School-Ltd/254020802079?ref=nf"><img alt="Facebook" src="images/facebook.png" /></a>
    <a rel="external" href="http://twitter.com/storm_driving"><img alt="Facebook" src="images/twitter.png" /></a>
    </div>

    <div data-role="footer" data-theme="a">
    <h4>&copy; 2006 STORM&reg; Driving School</h4>
    <p id="rcws"><a href="http://www.rcwebsolutions.co.uk" target="_blank" title="Website Design and Maintenance by Rob Cook Web Solutions">Website Design &amp; Maintenance</a><br />by <a href="http://www.rcwebsolutions.co.uk" target="_blank" title="Website Design and Maintenance by Rob Cook Web Solutions">Rob Cook Web Solutions</a></p>
    </div>
    </div>
    </div>
    </body>
    </html>

    Thanks in advance

  2. #2
    Join Date
    Sep 2008
    Posts
    95
    I cut and pasted your code and it doesn't throw the error for me. It says "An email has been successfully sent!"


    For me, an 'unexpected T_STRING' error often means that I'm missing a semi-colon ";" on the line before the error. But, like I said, I don't get the error for your script. Are there any required or included files before line 48 but not shown in the script above?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles