Jump to content

[SOLVED] Form post not working


ShaolinF

Recommended Posts

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 = "[email protected]";  
$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");

?>

Link to comment
https://forums.phpfreaks.com/topic/62397-solved-form-post-not-working/
Share on other sites

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

<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 = "[email protected]";  
$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");

?>

<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 = "[email protected]";  
$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");

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.