Jump to content

Trouble with if and get command


deeej

Recommended Posts

Hey guys hope some one can help ill try explain it as best i can.

the trouble is i cannot seem to get the id= to carry across so when the user logs in it takes them back to the page they wer at before.

it starts like this, >>
when you are on the resteraunt page you would like to add a testimonial for,
> you click add testimonial,
> for example if you were on le petit blanc resteraunt it would say in the url bar add_testimonial.php?id=2 (because the id of the resteraunt you are leaving a testimonial for is id=2.)
>in the add_testimonial.php page there is a little script to say if logged in continue if not to include login.php, (so the user must login before being able to leave a testimonial.

>in login.php this is where i have the if and get command.

>the idea is if you logged from how i just explained for it to take you back to the add_testimonial.php?id=2 page.(once oyou have logged in)

>but you can also login from the home page,
>for example: by clicking login on the home page, this is where the if command comes in,
>if they login from the home page there would be no ?id=2 so there for i would like them to be taken to the home page when logged in.

[b] This is the add_testimonial.php page.

which would be displayed like this in the url page
add_testimonial.php?id=123
[/b]
<?php
session_start();
if (isset ($_SESSION['loggedin']) && isset ($_SESSION['time']))
{
?>
<form method="POST" name="t1" OnSubmit="return CheckTestimonial();">

<table align="center">
<caption align="center" class="TitleLinks">Add your testimonial</caption>

<tr>
<td align="right">Your name: </td>
<td><input type="text" name="testimonial_name"></td>
</tr>

<tr>
<td align="right" valign="top">Testimonial: </td>
<td><textarea rows="5" cols="40" name="testimonial_text"></textarea></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="s1" value="Submit"></td>
</tr>

</table>

</form>
<?php
}
else
{
include ("login1.php");
}
?>

[b]this is the code i have so far that is in the login.php page with the if get command[/b]

$id = $_GET["id"];
if($id != ''){
header ("Location: add_testimonial.php?id=$id");
exit;
}
else
{
header ('Location: index.php');
exit;
}
exit;
}

[b]Also tried echoing the id but it does not seem to show in the login page i am wondering if it something to do with the if get command being in the login page and the login page being an include to the add_testimonial page.

Thanks guys[/b]
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.