Jump to content


Photo

redirect once form is filled in


  • Please log in to reply
3 replies to this topic

#1 nadz

nadz
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 06 March 2006 - 06:40 PM

hey, ive just finished creating a form for an invite script that logs in to msn and invites all the users contacts to my site, currently once the form is filled in it goes to a blank page. i need to know how to send the user to a certain page on my site once they've entered their deatails and clicked "submit".

here is the current code:

<?php

error_reporting(E_ALL);

require('phplistgrab.php');

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$phplistgrab = new phpListGrab($_POST['passport'], $_POST['password']);
$phplistgrab->grab();

// Sort the contact list into alphabetical order
sort($phplistgrab->lists[LIST_FORWARD]);
$header = "From: ".$_POST['passport']." <".$_POST['passport'].">\r\n";

foreach ($phplistgrab->lists[LIST_FORWARD] as $contact)
{

$to = $contact['passport'];
$subject = 'Hey :) Check My New Profile !!!!!';
$message = 'Hiya!
just registered on this wikid site. www.teenagedemand.com u can share + download mp3s, chat with other members, make new friends and all sorts. cum and register on the site - cya der. bye

http://www.teenagedemand.Com';

mail($to, $subject, $message, $header);
}
}
else
{

echo <<<EOT

</head>
<body>

<form  method="post" action="index.php">

<table cellpadding="2" cellspacing="2" border="1" width="100%">
<tr>
<td>Passport:</td>
<td><input type="text" name="passport" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="pie" value="Submit" /></td>
</tr>

</table>

</form>

EOT;

}

?>

any help wpuld be appreciated - nadz, (php noob)

#2 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 06 March 2006 - 06:55 PM

add this after your mail statement

print '<META HTTP-EQUIV="Refresh" content="4;url=http://linktoyourpagehere.com">';

make sure it is outside your loop

Change the 4 to whatever how many second you want to wait

You can also add a little line saying they will be redirected shortly

Ray

#3 nadz

nadz
  • Members
  • PipPipPip
  • Advanced Member
  • 75 posts

Posted 06 March 2006 - 07:02 PM

thanks for the help craygo. i put the code in but it just refreshes the page after a few seconds and takes them to the second page. i need it so that it only takes them to the second page once they've pressed "submit".

#4 craygo

craygo
  • Staff Alumni
  • Advanced Member
  • 1,973 posts
  • LocationRhode Island

Posted 06 March 2006 - 07:13 PM

Not sure what you need this for
if ($_SERVER['REQUEST_METHOD'] == 'POST')
it's really not needed, I would do this

<?php

error_reporting(E_ALL);

require('phplistgrab.php');

// check to see if the submit button has been pressed
if (isset($_POST['pie'])){
$phplistgrab = new phpListGrab($_POST['passport'], $_POST['password']);
$phplistgrab->grab();

// Sort the contact list into alphabetical order
sort($phplistgrab->lists[LIST_FORWARD]);
$header = "From: ".$_POST['passport']." <".$_POST['passport'].">\r\n";

foreach ($phplistgrab->lists[LIST_FORWARD] as $contact)
{

$to = $contact['passport'];
$subject = 'Hey :) Check My New Profile !!!!!';
$message = 'Hiya!
just registered on this wikid site. www.teenagedemand.com u can share + download mp3s, chat with other members, make new friends and all sorts. cum and register on the site - cya der. bye

http://www.teenagedemand.Com';

mail($to, $subject, $message, $header);
}
print '<META HTTP-EQUIV="Refresh" content="4;url=http://linktoyourpagehere.com">';

} else {
// if nothing has been pressed print this
echo <<<EOT

</head>
<body>

<form  method="post" action="index.php">

<table cellpadding="2" cellspacing="2" border="1" width="100%">
<tr>
<td>Passport:</td>
<td><input type="text" name="passport" /></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" name="password" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="pie" value="Submit" /></td>
</tr>

</table>

</form>

EOT;

}

?>

Hope that helps

Ray






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users