Can someone tell me whats wrong in this code?

  • balko
  • Beginner
  • Beginner
  • balko
  • Posts: 39
  • Loc: Lancaster, Pa

Post 3+ Months Ago

It keeps saying something is wrong (the error message thing)

And, I have no clue cuz i don't even know php, and my friend who made it hasn't came online for like a week.
PHP Code: [ Select ]
<html>
 
<head>
 
<title>Submit Work</title>
 
</head>
 
<body>
 
<?php
 
$form ="<form action=\"PHP_SELF\" method=\"post\">";
 
$form .="Your Name:<input type=\"text\" name=\"name\" size=\"30\">";
 
$form .="<br><br>";
 
$form .="Your Email Address:  <input type=\"text\" name=\"email\" size=\"30\">";
 
$form .="<br><br>";
 
$form .="Piece to Submit:  <textarea name="\"piece\" cols=\"30\" rows=\"7\">";
 
$form .="</textarea><br>";
 
$form .="<input type=\"submit\" name=\"sent\" value=\"Submit Work!\">";
 
$form .="</form>";
 
 
 
if($sent)
 
{
 
$valid=true;
 
   {
 
   if( !$name )
 
   { $errmsg .="Please enter your name."<br>";
 
   $valid = false;
 
   }
 
   if( !$email )
 
   { $errmsg .="Please enter your email address.<br>";
 
   $valid = false;
 
   }
 
   if( !$piece )
 
   { $errmsg .="Please enter the piece you wish to submit.<br>";
 
   $valid = false;
 
   }
 
   }
 
if($valid!=true)
 
{echo( $errmsg.$form );
 
}
 
 
 
else
 
{
 
$to = "admin@iwillspeak.us";
 
$re = "Submission of a piece from $name";
 
$msg = "$piece";
 
$headers = "From: $email \r\n";
 
 
 
if(mail($to,$re,$msg, $headers))
 
   {
 
   echo("Thanks for submitting a piece of your work, $name.");
 
   }
 
}
 
?>
 
</body></html>
  1. <html>
  2.  
  3. <head>
  4.  
  5. <title>Submit Work</title>
  6.  
  7. </head>
  8.  
  9. <body>
  10.  
  11. <?php
  12.  
  13. $form ="<form action=\"PHP_SELF\" method=\"post\">";
  14.  
  15. $form .="Your Name:<input type=\"text\" name=\"name\" size=\"30\">";
  16.  
  17. $form .="<br><br>";
  18.  
  19. $form .="Your Email Address:  <input type=\"text\" name=\"email\" size=\"30\">";
  20.  
  21. $form .="<br><br>";
  22.  
  23. $form .="Piece to Submit:  <textarea name="\"piece\" cols=\"30\" rows=\"7\">";
  24.  
  25. $form .="</textarea><br>";
  26.  
  27. $form .="<input type=\"submit\" name=\"sent\" value=\"Submit Work!\">";
  28.  
  29. $form .="</form>";
  30.  
  31.  
  32.  
  33. if($sent)
  34.  
  35. {
  36.  
  37. $valid=true;
  38.  
  39.    {
  40.  
  41.    if( !$name )
  42.  
  43.    { $errmsg .="Please enter your name."<br>";
  44.  
  45.    $valid = false;
  46.  
  47.    }
  48.  
  49.    if( !$email )
  50.  
  51.    { $errmsg .="Please enter your email address.<br>";
  52.  
  53.    $valid = false;
  54.  
  55.    }
  56.  
  57.    if( !$piece )
  58.  
  59.    { $errmsg .="Please enter the piece you wish to submit.<br>";
  60.  
  61.    $valid = false;
  62.  
  63.    }
  64.  
  65.    }
  66.  
  67. if($valid!=true)
  68.  
  69. {echo( $errmsg.$form );
  70.  
  71. }
  72.  
  73.  
  74.  
  75. else
  76.  
  77. {
  78.  
  79. $to = "admin@iwillspeak.us";
  80.  
  81. $re = "Submission of a piece from $name";
  82.  
  83. $msg = "$piece";
  84.  
  85. $headers = "From: $email \r\n";
  86.  
  87.  
  88.  
  89. if(mail($to,$re,$msg, $headers))
  90.  
  91.    {
  92.  
  93.    echo("Thanks for submitting a piece of your work, $name.");
  94.  
  95.    }
  96.  
  97. }
  98.  
  99. ?>
  100.  
  101. </body></html>

I don't know it if shows up...
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

please use the code or php tags when posting. thanks. :D
  • b_heyer
  • Web Master
  • Web Master
  • User avatar
  • Posts: 4581
  • Loc: Maryland

Post 3+ Months Ago

Well without a real "error message thing" I can't tell you much, but for starters this line is incorrect:

PHP Code: [ Select ]
 
    { $errmsg .="Please enter your name."<br>";
 
 
  1.  
  2.     { $errmsg .="Please enter your name."<br>";
  3.  
  4.  


It needs to read:
PHP Code: [ Select ]
 
    { $errmsg .="Please enter your name.<br>";
 
 
  1.  
  2.     { $errmsg .="Please enter your name.<br>";
  3.  
  4.  
  • balko
  • Beginner
  • Beginner
  • balko
  • Posts: 39
  • Loc: Lancaster, Pa

Post 3+ Months Ago

sorry...i forgot. lol.



these are the error messages:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/balko/public_html/form.php on line 12

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/balko/public_html/form.php on line 12


I edited the part you told me too...
  • _Leo_
  • Proficient
  • Proficient
  • User avatar
  • Posts: 279
  • Loc: Buenos Aires, Argentina

Post 3+ Months Ago

You have to check the syntax of the file, you are not escaping all the doble quotations marks:

PHP Code: [ Select ]
$form .="Piece to Submit:  <textarea name=""piece\" cols=\"30\" rows=\"7\">";
Here, after name= you have to add a back slash.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Yup, Leo's right, there's a typo on that line... "" instead of \"
  • Tannu4u
  • Proficient
  • Proficient
  • User avatar
  • Posts: 480
  • Loc: India

Post 3+ Months Ago

i think this will work for u


PHP Code: [ Select ]
<html>
 
<head>
 
<title>Submit Work</title>
 
</head>
 
<body>
 
<?
 
$form ="<form action=\"PHP_SELF\" method=\"post\">";
 
$form .="Your Name:<input type=\"text\" name=\"name\" size=\"30\">";
 
$form .="<br><br>";
 
$form .="Your Email Address:  <input type=\"text\" name=\"email\" size=\"30\">";
 
$form .="<br><br>";
 
$form .="Piece to Submit:  <textarea name=\"piece\" cols=\"30\" rows=\"7\">";
 
$form .="</textarea><br>";
 
$form .="<input type=\"submit\" name=\"sent\" value=\"Submit Work!\">";
 
$form .="</form>";
 
 
 
if(!isset($errmsg))
 
   $errmsg="";
 
if(isset($sent))
 
{
 
if(isset($valid))
 
   $valid=true;
 
 
 
    if(!$name)
 
    {
 
      $errmsg .="Please enter your name"."<br>";
 
      $valid = false;
 
    }
 
    if(!$email)
 
    { $errmsg .="Please enter your email address.<br>";
 
    $valid = false;
 
    }
 
    if(!$piece)
 
    { $errmsg .="Please enter the piece you wish to submit.<br>";
 
    $valid = false;
 
    }
 
}
 
 
 
if(isset($valid)!=true)
 
{
 
   echo( $errmsg.$form );
 
}
 
else
 
{
 
$to = "admin@iwillspeak.us";
 
$re = "Submission of a piece from $name";
 
$msg = "$piece";
 
$headers = "From: $email rn";
 
 
 
if(mail($to,$re,$msg, $headers))
 
    {
 
    echo("Thanks for submitting a piece of your work, $name.");
 
    }
 
}
 
?>
  1. <html>
  2.  
  3. <head>
  4.  
  5. <title>Submit Work</title>
  6.  
  7. </head>
  8.  
  9. <body>
  10.  
  11. <?
  12.  
  13. $form ="<form action=\"PHP_SELF\" method=\"post\">";
  14.  
  15. $form .="Your Name:<input type=\"text\" name=\"name\" size=\"30\">";
  16.  
  17. $form .="<br><br>";
  18.  
  19. $form .="Your Email Address:  <input type=\"text\" name=\"email\" size=\"30\">";
  20.  
  21. $form .="<br><br>";
  22.  
  23. $form .="Piece to Submit:  <textarea name=\"piece\" cols=\"30\" rows=\"7\">";
  24.  
  25. $form .="</textarea><br>";
  26.  
  27. $form .="<input type=\"submit\" name=\"sent\" value=\"Submit Work!\">";
  28.  
  29. $form .="</form>";
  30.  
  31.  
  32.  
  33. if(!isset($errmsg))
  34.  
  35.    $errmsg="";
  36.  
  37. if(isset($sent))
  38.  
  39. {
  40.  
  41. if(isset($valid))
  42.  
  43.    $valid=true;
  44.  
  45.  
  46.  
  47.     if(!$name)
  48.  
  49.     {
  50.  
  51.       $errmsg .="Please enter your name"."<br>";
  52.  
  53.       $valid = false;
  54.  
  55.     }
  56.  
  57.     if(!$email)
  58.  
  59.     { $errmsg .="Please enter your email address.<br>";
  60.  
  61.     $valid = false;
  62.  
  63.     }
  64.  
  65.     if(!$piece)
  66.  
  67.     { $errmsg .="Please enter the piece you wish to submit.<br>";
  68.  
  69.     $valid = false;
  70.  
  71.     }
  72.  
  73. }
  74.  
  75.  
  76.  
  77. if(isset($valid)!=true)
  78.  
  79. {
  80.  
  81.    echo( $errmsg.$form );
  82.  
  83. }
  84.  
  85. else
  86.  
  87. {
  88.  
  89. $to = "admin@iwillspeak.us";
  90.  
  91. $re = "Submission of a piece from $name";
  92.  
  93. $msg = "$piece";
  94.  
  95. $headers = "From: $email rn";
  96.  
  97.  
  98.  
  99. if(mail($to,$re,$msg, $headers))
  100.  
  101.     {
  102.  
  103.     echo("Thanks for submitting a piece of your work, $name.");
  104.  
  105.     }
  106.  
  107. }
  108.  
  109. ?>


Moderator Edit : Tannu4u, please learn to use the [code] & [php] tags.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 164 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.