Jump to content


Photo

Hyperlinking Question


  • Please log in to reply
4 replies to this topic

#1 randalw

randalw
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 28 February 2006 - 10:21 PM

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:

<?php
if ($_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_name

Last Name = $last_name

Phone = $phone

Email Address = $email

State = $state


Host: $host
Time: $ts";

$email = "From: Form <$to>";
mail($to, $subject, $body, $email);
?>

<html>
<head>
<title>Email Sent</title>
</head>
<body bgcolor="#ffffff" text="#666666">

<p>&nbsp;</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
}
?>


#2 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 28 February 2006 - 10:26 PM

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?

#3 randalw

randalw
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 01 March 2006 - 02:22 PM

[!--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) View Post[/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)


#4 randalw

randalw
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 03 March 2006 - 04:39 PM

[!--quoteo(post=350617:date=Mar 1 2006, 08:22 AM:name=randal)--][div class=\'quotetop\']QUOTE(randal @ Mar 1 2006, 08:22 AM) View Post[/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]



#5 php_b34st

php_b34st
  • Members
  • PipPipPip
  • Advanced Member
  • 168 posts

Posted 03 March 2006 - 05:49 PM

try:

if (mail($to, $subject, $body, $email))
{
    header("Location: http://www.gasmoneysaver.net");
}
else
{
    echo 'Could not send email.';
}





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users