randalw Posted February 28, 2006 Share Posted February 28, 2006 I new to PHP. Following is my code. I need my submit button, once the form is filled and they hit submit to go to the following website [a href=\"http://www.gasmoneysaver.net\" target=\"_blank\"]http://www.gasmoneysaver.net[/a]Can you tell me what the code should be to make this happen?CODE:<?phpif ($_POST['first_name'] != "" && $_POST['last_name'] && $_POST['phone'] && $_POST['email'] && $_POST['state'] ) {$subject="GC Form";$ip=$_SERVER["REMOTE_ADDR"];$host = $ip;$mon=date(m);$day=date(j);$year=date(y);$hour=date(g);$min=date(i);$sec=date(s);$hour=$hour-2;if($hour<=0) { $hour+=12; }$ts = "$hour:$min:$sec on $day/$mon/$year";$to="randal@500kmentor.com";$body="First Name = $first_nameLast Name = $last_namePhone = $phoneEmail Address = $emailState = $stateHost: $hostTime: $ts";$email = "From: Form <$to>";mail($to, $subject, $body, $email);?><html><head><title>Email Sent</title></head><body bgcolor="#ffffff" text="#666666"><p> </p><center><table border="1" cellpadding="3" cellspacing="0" width="400" bordercolor="#919191" bgcolor="#E6E6E6"> <tr> <td width="100%"> <p><center><b><font color="#000000">Email was successfully sent to: <?php echo $to ?></font></b></center> </td> </tr></table></body></html><?php} else {?><html><head> <title>Contact email error</title></head><body bgcolor="#ffffff" text="#666666"><p><center><table border="1" cellpadding="3" cellspacing="0" width="400" bordercolor="#919191" bgcolor="#E6E6E6"> <tr> <td width="100%"> <center> <b>There was an error with processing the email.</b><br> <p> <font color="#FF0000">Errors where:</font><br> <?php If (!$_POST['first_name']) echo "First Name field is empty<br>"; If (!$_POST['last_name']) echo "Last Name field is empty<br>"; If (!$_POST['phone']) echo "Phone field is empty<br>"; If (!$_POST['email']) echo "Email Address field is empty<br>"; If (!$_POST['state']) echo "State field is empty<br>"; ?> <p> Email message wasn't sent </td> </tr></table></body></html><?php}?> Quote Link to comment Share on other sites More sharing options...
php_b34st Posted February 28, 2006 Share Posted February 28, 2006 Do you own that site? if not i dont think there is a way that you can post data to it because you need to add code to that site so that it can recieve the data. Or do u just want that site to open without posting data to it?I just had a look and your name is on the site so i guess you do own it. Do you want to go to that site instead of displaying "Email was successfully sent to: <?php echo $to ?>" or instead of that? Quote Link to comment Share on other sites More sharing options...
randalw Posted March 1, 2006 Author Share Posted March 1, 2006 [!--quoteo(post=350412:date=Feb 28 2006, 04:26 PM:name=php_b34st)--][div class=\'quotetop\']QUOTE(php_b34st @ Feb 28 2006, 04:26 PM) [snapback]350412[/snapback][/div][div class=\'quotemain\'][!--quotec--]Do you own that site? if not i dont think there is a way that you can post data to it because you need to add code to that site so that it can recieve the data. Or do u just want that site to open without posting data to it?I just had a look and your name is on the site so i guess you do own it. Do you want to go to that site instead of displaying "Email was successfully sent to: <?php echo $to ?>" or instead of that?[/quote]If the form is successful I want to go to www.gasmoneysaver.net I do not care if it displays iformation after the submit button. All I care about is it going to my website and emailing me the form data (which works fine now) Quote Link to comment Share on other sites More sharing options...
randalw Posted March 3, 2006 Author Share Posted March 3, 2006 [!--quoteo(post=350617:date=Mar 1 2006, 08:22 AM:name=randal)--][div class=\'quotetop\']QUOTE(randal @ Mar 1 2006, 08:22 AM) [snapback]350617[/snapback][/div][div class=\'quotemain\'][!--quotec--]If the form is successful I want to go to www.gasmoneysaver.net I do not care if it displays iformation after the submit button. All I care about is it going to my website and emailing me the form data (which works fine now)[/quote] Quote Link to comment Share on other sites More sharing options...
php_b34st Posted March 3, 2006 Share Posted March 3, 2006 try:[code]if (mail($to, $subject, $body, $email)){ header("Location: http://www.gasmoneysaver.net");}else{ echo 'Could not send email.';}[/code] 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.