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 = "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");

?>

Link to comment
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

Link to comment
Share on other sites

<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");

?>

Link to comment
Share on other sites

<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");

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.