Jump to content


Photo

Trouble with if and get command


  • Please log in to reply
1 reply to this topic

#1 deeej

deeej
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 15 September 2006 - 09:16 AM

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.

This is the add_testimonial.php page.

which would be displayed like this in the url page
add_testimonial.php?id=123

<?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");
}
?>

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

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

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


#2 deeej

deeej
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 15 September 2006 - 01:40 PM

also i tried carrying the id with include login.php?id=$id but it cannot find the login page then.

Thanks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users