NameSilo

What's wrong with this

Spaceship Spaceship
Watch
Impact
19
PHP:
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post">
Your Name: <input type="text" name="name" size="20"><br>
Your Email: <input type="text" name="email" size="20"><br><br>
Friends Email: <input type="text" name="id" size="20"><br>
<input type="submit" value="Submit">
</form>
<?php
$name=$_POST['name'];
$email=$_POST['email'];
$header=$_POST['subject'];
$comments= "Hi" . $POST['name']
"I was surfing the net when i came across [url]http://www.funnymedia.net[/url], And Its AWESOME, I THINK YOU MUST CHECK IT!.";
$to=$_POST['id'];
$message=$comments;
if(mail($to,$header,$message,"From: $email\n")) {
echo "Thanks for Telling your friend about our website, THe email has been succesfully SEND.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>

Can anyone tell me whats wrong wid tht code? Its not working :(
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
what doesnt work about it?
 
0
•••
First, you see to be doing the PHP_SELF portion wrong (correct me if IM wrong ppl :P)

You need a name attribute to the Submit button.

PHP:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post"> 
  Your Name: <input type="text" name="name" size="20"><br> 
  Your Email: <input type="text" name="email" size="20"><br><br> 
  Friends Email: <input type="text" name="id" size="20"><br> 
<input type="submit" name="Submit" value="Submit"> 
</form> 
<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$header = $_POST['subject']; 
$to = $_POST['id'];

// Just use the $name variable. No sense in creating it if you aren't going to use it.
$comments= "Hi " . $name . "<br><br>I was surfing the net when i came across [url]http://www.funnymedia.net[/url], And Its AWESOME, I THINK YOU MUST CHECK IT!."; 
 
// You don't need this, just use the comments variable.
// $message = $comments; 
//

// Check if user submitted
if ($_POST['Submit'] === "Submit")
{
    if ( mail($to, $header, $comment, "From: ".$email."\n") )
    { 
        echo "Thanks for Telling your friend about our website, The email has been succesfully SENT."; 
    }
    else
    { 
        echo "There was a problem sending the mail. Please check that you filled in the form correctly."; 
    }
}
?>


I would also suggest you check that each email is, in fact, an email.

Try this, Im not sure if it works :-/
 
0
•••
ok well right of the bat i caught 2 errors, and that was not even halfway thru. so what i changed is that i added name="Submit" to the submit button, i put a concatenation . between $POST['name'] and the rest of the sentence, i changed $POST['name'] to $_POST['name'], and when u define $header, there is no $_POST['subject'] input. hope this helps.

PHP:
<form action="<?php $_SERVER['PHP_SELF'];?>" method="post"> 
Your Name: <input type="text" name="name" size="20"><br> 
Your Email: <input type="text" name="email" size="20"><br><br> 
Friends Email: <input type="text" name="id" size="20"><br> 
<input type="submit" name="Submit" value="Submit"> 
</form> 
<?php 
$name=$_POST['name']; 
$email=$_POST['email']; 
$header=$_POST['subject']; 
$comments= "Hi" . $_POST['name'] . "I was surfing the net when i came across [url]http://www.funnymedia.net[/url], And Its AWESOME, I THINK YOU MUST CHECK IT!"; 
$to=$_POST['id']; 
$message=$comments; 
if(mail($to,$header,$message,"From: $email\n")) { 
echo "Thanks for Telling your friend about our website, THe email has been succesfully SEND."; 
} else { 
echo "There was a problem sending the mail. Please check that you filled in the form correctly."; 
} 
?>
 
0
•••
ya it worked :D thanks
 
0
•••
no problemo. got any more questions?
 
0
•••
not right now but i will let u guyz know if i need more help :D

Outer said:
First, you see to be doing the PHP_SELF portion wrong (correct me if IM wrong ppl :P)

You need a name attribute to the Submit button.

PHP:
<form action="<?=$_SERVER['PHP_SELF']?>" method="post"> 
  Your Name: <input type="text" name="name" size="20"><br> 
  Your Email: <input type="text" name="email" size="20"><br><br> 
  Friends Email: <input type="text" name="id" size="20"><br> 
<input type="submit" name="Submit" value="Submit"> 
</form> 
<?php 
$name = $_POST['name']; 
$email = $_POST['email']; 
$header = $_POST['subject']; 
$to = $_POST['id'];

// Just use the $name variable. No sense in creating it if you aren't going to use it.
$comments= "Hi " . $name . "<br><br>I was surfing the net when i came across [url]http://www.funnymedia.net[/url], And Its AWESOME, I THINK YOU MUST CHECK IT!."; 
 
// You don't need this, just use the comments variable.
// $message = $comments; 
//

// Check if user submitted
if ($_POST['Submit'] === "Submit")
{
    if ( mail($to, $header, $comment, "From: ".$email."\n") )
    { 
        echo "Thanks for Telling your friend about our website, The email has been succesfully SENT."; 
    }
    else
    { 
        echo "There was a problem sending the mail. Please check that you filled in the form correctly."; 
    }
}
?>


I would also suggest you check that each email is, in fact, an email.

Try this, Im not sure if it works :-/


I tried this and it works except when i send the email...it sends it wid NOTHING in it..so it sends a EMPTY email...:(
 
0
•••
PHP:
$comments= "Hi " . $name . "<br><br>I was surfing the net when i came across [url]http://www.funnymedia.net[/url], And Its AWESOME, I THINK YOU MUST CHECK IT!.";

PHP:
if ( mail($to, $header, $comment, "From: ".$email."\n") )

$comments!=$comment
 
0
•••
ah okay :p fixed tht
but HTML is not working

thts wt i get


Hi Zubair<br><br>I was surfing the net when i came across http://www.funnymedia.net, And Its AWESOME, I THINK YOU MUST CHECK IT!.

so the <br> doesnt take effect....and the URL doesnt take effect either
 
0
•••
ah, my mistake ;)

replace the <br>'s with:
PHP:
\r\n

SO
PHP:
$comments = "Hi " . $name . "\r\n
\r\n
I was surfing the net when i came across [url]http://www.funnymedia.net[/url], And Its AWESOME, I THINK YOU MUST CHECK IT!.";

My mistake about the comments one, that slipped my grasp! :P
 
0
•••
and what abt the URL tag
 
0
•••
Remove url tag in the email the software will auto parse it as http link..

iNod
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back