Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PHP script syntax error help!!

Guest
Nov 16, 2010 Nov 16, 2010

Here is my code im trying to use and its telling me theres an error on line 19. ive been struggling with this for 2 days now and need some help

from someone who actually knows what theyre doing

<?php
  $email=addslashes($_POST['email']);
  $order=addslashes($_POST['order']);
  $cardtype=addslashes($_POST['cardtype']);
  $cardnumber=addslashes($_POST['cardnumber']);
  $expmonth=addslashes($_POST['expmonth']);
  $expyear=addslashes($_POST['expyear']);

// you can specify which email you want your contact form to be emailed to here

  $toemail = "[email address deleted by moderator]";
  $subject = "Online Order";

  $headers = "MIME-Version: 1.0\n"
            ."From: \"".$name."\" <".$email.">\n"
            ."Content-type: text/html; charset=iso-8859-1\n";

 
  $body = "Email: ".$email."<br>\n"
            ."Email: ".$email."<br>\n"
            ."order:<br>\n"
            .$order;
            ."cardtype:<br>\n"
            .$cardtype;

  if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
  {
    echo "That is not a valid email address.  Please return to the"
           ." previous page and try again.";
    exit;
  }

    mail($toemail, $subject, $body, $headers);
    echo "Thanks for submitting your comments";
?>

[Email address deleted by moderator]  if u have any answers an email or post reply would be greatly appreciated

TOPICS
Server side applications
472
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 18, 2010 Nov 18, 2010
LATEST

Please do not hijack other people's threads with new questions. Always start a separate thread of your own. See How to get help quickly for advice on how to use the forums efficiently.

The problem with your code lies in this section:

  $body = "Email: ".$email."<br>\n"
            ."Email: ".$email."<br>\n"
            ."order:<br>\n"
            .$order;
            ."cardtype:<br>\n"
            .$cardtype;

The semicolon after $order ends the statement. Change it like this:

$body = "Email: ".$email."<br>\n"
            ."Email: ".$email."<br>\n"
            ."order:<br>\n"
            ."$order<br>\n"
            ."cardtype:<br>\n"
            .$cardtype;

You should also avoid using ereg(). It has been deprecated, which means it will be removed from a future version of PHP (see http://docs.php.net/manual/en/function.ereg.php).

Use preg_match() instead.

if (!preg_match("/^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$/", $email))

preg_match() is very similar, except it uses PCRE regular expressions. In this case, the only diffference is the addition of slashes at the beginning and end of the regular expression. See http://docs.php.net/manual/en/function.preg-match.php.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines