By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,591 Members | 629 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,591 IT Pros & Developers. It's quick & easy.

How can change the error

P: 1
Parse error: syntax error, unexpected T_STRING in /home/glass9st/public_html/DEMO1/contact.php on line 7



In php code below

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /* Set e-mail recipient */
  3. $myemail  = "cvinod46@gmail.com";
  4.  
  5. /* Check all form inputs using check_input function */
  6. $yourname = check_input($_POST['yourname'], "Enter your name");
  7. $subject  = check_input($_POST['subject'], "Write a subject");
  8. $email    = check_input($_POST['email']);
  9. $website  = check_input($_POST['website']);
  10. $likeit   = check_input($_POST['likeit']);
  11. $how_find = check_input($_POST['how']);
  12. $comments = check_input($_POST['comments'], "Write your comments");
  13.  
  14. /* If e-mail is not valid show error message */
  15. if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
  16. {
  17.     show_error("E-mail address not valid");
  18. }
  19.  
  20. /* If URL is not valid set $website to empty */
  21. if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
  22. {
  23.     $website = '';
  24. }
  25.  
  26. /* Let's prepare the message for the e-mail */
  27. $message = "Hello!
  28.  
  29. Your contact form has been submitted by:
  30.  
  31. Name: $yourname
  32. E-mail: $email
  33. URL: $website
  34.  
  35. Like the website? $likeit
  36. How did he/she find it? $how_find
  37.  
  38. Comments:
  39. $comments
  40.  
  41. End of message
  42. ";
  43.  
  44. /* Send the message using mail() function */
  45. mail($myemail, $subject, $message);
  46.  
  47. /* Redirect visitor to the thank you page */
  48. header('Location: thanks.html');
  49. exit();
  50.  
  51. /* Functions we used */
  52. function check_input($data, $problem='')
  53. {
  54.     $data = trim($data);
  55.     $data = stripslashes($data);
  56.     $data = htmlspecialchars($data);
  57.     if ($problem && strlen($data) == 0)
  58.     {
  59.         show_error($problem);
  60.     }
  61.     return $data;
  62. }
  63.  
  64. function show_error($myError)
  65. {
  66. ?>
  67.     <html>
  68.     <body>
  69.  
  70.     <b>Please correct the following error:</b><br />
  71.     <?php echo $myError; ?>
  72.  
  73.     </body>
  74.     </html>
  75. <?php
  76. exit();
  77. }
  78. ?>

what can i do
Oct 5 '11 #1
Share this Question
Share on Google+
1 Reply


omerbutt
100+
P: 638
i didnt get any errors its working correctly try to check if there is any extra space after <?php starting tag
regards
Omer Aslam
Oct 5 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.