ShaolinF Posted July 30, 2007 Share Posted July 30, 2007 Hi Guys, I've made a small script where my users can enter their usernames into a form and when they press submit it sends the username to me as an email. It doesn't seem to be working though. Check the code: This is the HTML page: <form method="post" action="redirect.php" onsubmit="return Submitted(this);"> <input type="hidden" name="username1" id="username1" value="tech" size="20" /> <script language="javascript"> <!-- function Submitted(form) { if(form.validator.value == "") { window.location="retry.php"; return false; } } //--> </script> <button type="submit" value="Continue">Continue</button> Redirect.php script: <?php //add cookie $value = 'visit'; setcookie("visit", $value, time()+103200); /* expires in 24+ hours */ //grab IP $ip = ('IP: '.$_SERVER['REMOTE_ADDR'].'.'); //send email $msg .= ".\n"; $msg .= "Email: $username1\n"; $msg .= "IP: $ip\n"; $msg .= ".\n"; $to = "myemail@googlemail.com"; $subject = "Mail"; $mailheaders = "From: $Email <> \n"; $mailheaders .= "Reply-To: $sender_email\n\n"; mail($to, $subject, $msg, $mailheaders); //redirect header ("location: http://www.redirectsite.com"); ?> Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted July 30, 2007 Share Posted July 30, 2007 ive had this problem before. firstly, are you actually receiving the email? i know that ive had a similar script, that hasnt sent the email. and i think that the javascript function was overiding the form submit thingy. which means that you may have to include javascript to actually a) submit the form or b0 send the data to the next page. hope that helps Quote Link to comment Share on other sites More sharing options...
ShaolinF Posted July 30, 2007 Author Share Posted July 30, 2007 I get the email, the IP shows but the username doesnt. Quote Link to comment Share on other sites More sharing options...
ShaolinF Posted July 30, 2007 Author Share Posted July 30, 2007 Any ideas people ? ??? I still can't work it out. Quote Link to comment Share on other sites More sharing options...
jitesh Posted July 30, 2007 Share Posted July 30, 2007 Its shows <form> Where is </form> ? Quote Link to comment Share on other sites More sharing options...
ShaolinF Posted July 30, 2007 Author Share Posted July 30, 2007 Sorry I forgot to include that in the code. It's in the original though. Argh everything is right, why isnt it working..! Quote Link to comment Share on other sites More sharing options...
jitesh Posted July 30, 2007 Share Posted July 30, 2007 Why if(form.validator.value == "") ? I do not found "validator" in form. Quote Link to comment Share on other sites More sharing options...
ShaolinF Posted July 30, 2007 Author Share Posted July 30, 2007 Sorry that was some other input field which I've removed now. Quote Link to comment Share on other sites More sharing options...
jitesh Posted July 30, 2007 Share Posted July 30, 2007 Now post code After removing unneccasary items. Quote Link to comment Share on other sites More sharing options...
ShaolinF Posted July 30, 2007 Author Share Posted July 30, 2007 <form method="post" action="redirect.php"> <input type="text" name="Email" id="Email" value="tech" size="20" /> <button type="submit" value="Continue">Continue</button> <?php //grab IP $ip = ('EE: '.$_SERVER['REMOTE_ADDR'].'.'); //send email $msg = "Email\n"; $msg .= ".\n"; $msg .= "Email: $Email\n"; $msg .= "IP: $ip\n"; $msg .= ".\n"; $to = "mymail@googlemail.com"; $subject = "Email"; $mailheaders = "From: $Email <> \n"; $mailheaders .= "Reply-To: $sender_email\n\n"; mail($to, $subject, $msg, $mailheaders); //redirect header ("location: http://www.site.com"); ?> Quote Link to comment Share on other sites More sharing options...
jitesh Posted July 30, 2007 Share Posted July 30, 2007 <form method="post" name="frmemail" action="redirect.php"> <input type="text" name="Email" id="Email" value="tech" size="20" /> <button type="submit" value="Continue">Continue</button> </form> <?php //grab IP $ip = ('EE: '.$_SERVER['REMOTE_ADDR'].'.'); //send email $msg = "Email\n"; $msg .= ".\n"; $msg .= "Email: ".$_POST['Email']."\n"; $msg .= "IP: $ip\n"; $msg .= ".\n"; $to = "mymail@googlemail.com"; $subject = "Email"; $mailheaders = "From: $Email <> \n"; $mailheaders .= "Reply-To: $sender_email\n\n"; mail($to, $subject, $msg, $mailheaders); //redirect header ("location: http://www.site.com"); ?> Quote Link to comment Share on other sites More sharing options...
ShaolinF Posted July 30, 2007 Author Share Posted July 30, 2007 Excellent. Worked a charm. Thanks ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.