Jump to content

redirect once form is filled in


nadz

Recommended Posts

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:

[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;

}

?>[/code]

any help wpuld be appreciated - nadz, (php noob)
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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".
Link to comment
Share on other sites

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

[code]
<?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;

}

?>[/code]

Hope that helps

Ray

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.