Forum Moderators: coopster

Message Too Old, No Replies

Header redirect

         

Mark1978

7:39 pm on Jun 28, 2010 (gmt 0)

10+ Year Member



Hi Guys,
I have a form below which basically gives a user the ability to accept or reject people who signup to a site. This all works fine. There is also a contacts section within the cms that allows me to edit the contact.

What I need though is once the user has been accepted is then to redirect that new contact to be editable. I have added a header redirect which is redirecting to the specified page but how can I bring up the submitted contact/signup from the header? (hope this makes sense)

<?php

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<input type="hidden" name="action" value="submit" />
<input type="hidden" name="ID" value="<?php echo $r['id']; ?>" />

<label>Action:</label>
<select name="case">
<option value="">-- Choose an action --</option>
<option value="DeleteNo">Delete this signup</option>
<option value="DeleteYes">Reject and send email to user</option>
<option value="AcceptNo">Accept without sending out an email</option>
<option value="AcceptYes">Accept and send login link to user</option>
</select>

<p><input type="submit" value="Process &raquo" /></p>


<?php

if (isset($_POST['action']) && $_POST['action']=="submit") {
header("location: http://localhost:8888/admin/contacts/edit/?id=");
}
?>
</form>
</td>
</tr>
</table>

</div>
<?php } ?>

Matthew1980

7:54 pm on Jun 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Mark1978,

(hope this makes sense)

Well, not quite, it sounds like once the user signs up you want to redirect them to another page where they can edit their details? I think I am right there :) Quick answer to that is to use the $id and pass it in a $_SESSION['id']; that would be my first thought, but there again, depends on if you pass it in the URL (which would be easier).

Just a pointer here too as you are evaluating the contents of the key:-

if (isset($_POST['action']) && ($_POST['action'] == "submit")){
//process if true USED https so the integrity of the url remains, forum software mangles it else ;)
header("location: [exemplify...] number here?");
}
else{
//redirect back to form as error has occured
header("Location: signupPage.php");
exit;
}

Other than that I am not too sure what you are trying to do.

Cheers,
MRb

rocknbil

9:20 pm on Jun 28, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Given what you have there, I wouldn't redirect at all. Put it all in the same script. This is "baby code logic" to give you an idea.

if (isset($_POST['Action']) and ($_POST['Action']=='submit')) {
// Update the database or other action based on the selected Action
// select the record by the ID field in the approval form,
// use those values to pre-populate the form
// OUTPUT THE CONTACT EDIT FORM (if edit is selected)
// otherwise output a response (rejected, emailed, etc.)
}

else {
// output the approval form you have there
}

You'd have similar control structures to react to editing the data, etc.

Mark1978

9:40 am on Jun 29, 2010 (gmt 0)

10+ Year Member



Matt, Thanks for you reply but I want to try and post the id into the URL.

Matthew1980

11:23 am on Jun 29, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there mark1978,

Ok, that's no problem then, once you set the link up, you just set the receiving script/function/snippet to extract the info using $_GET, once you have that you can perform the relevant DB checks from that :)

WRT Rocknbils example, that would be a good way to handle things, no need to engineer things..

Cheers,
MRb