Redirect page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
khushbush
Forum Commoner
Posts: 99
Joined: Tue Mar 11, 2008 11:50 am

Redirect page

Post by khushbush »

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Ok...so my problem here is this:

As part of my property application, I'd like a user to search for a property and then place a bid on their chosen property if they like it.

I'd like the selected property to show up after login...so if the user wants to bid on a property, but has not logged in, then the user will click on a button called "Login to bid" which will take them to the login page...once the user has logged in, the page will then redirect back to the page showing the selected property, this time with a form to enter the bid value shown.

My main problem is trying to redirect the page from login back to the page of that particular property. That is my biggest issue...it seems like there's a simple answer to it...but I can't seem to find the solution to it :?

This is code from a file called bid.php:

Code: Select all

 
<HTML>
<BR>
<BR>
<TABLE align = "CENTER"><TR><TD><HEAD><font face="Arial" style = "font-size: 22pt" color="#0B3A62"> Property Bid</font></head></BR></BR></TD></TR></TABLE>
<body>
 
 
<font face="Arial" color="#0B3A62">
<form action = "bidprocess.php" method = "POST">
Bid value: <input type = "text" name = "bid" value = "">
<table align = "LEFT" VALIGN = "bottom">
<tr><td><form action = "bidprocess.php"><input type="submit" value="Bid on property"></form></td></tr></table>
<?
include "session.php";
 
mysql_connect("****", "****", "******") or die(mysql_error());
 
mysql_select_db("bid") or die(mysql_error()); 
 
$bid = addslashes($_POST['bidvalue']);
 
$q = "INSERT INTO bid VALUES ('$bid')";
       return mysql_query($q);
?>
</form>
</body>
</html>
 
And this is code from a file called bidprocess.php:

Code: Select all

 
if (isset($_GET['id'])) { 
 
 // Put the value in a separate variable
 $propID = mysql_real_escape_string($_GET['id']); 
 
 
$query = "select propertyArea, propertyPrice, propertyType, propertyBedrooms, propertyDescription from property where propertyID = $propID ORDER BY 'propertyID'";
$result = mysql_query($query);
 
 
while ($row = mysql_fetch_row($result))
{
?>
<table ALIGN = "LEFT">
<font face="Arial" color="#0B3A62">
  <?echo $row[0]; ?> , 
  £<? echo $row[1]; ?> , 
  <? echo $row[2]; ?> ,
  <? echo $row[3]; ?> bedrooms,
  <? echo $row[4]; ?> 
  <? echo $row[5];
  
echo "<a href=\"showimage.php?id=$row[propertyID]\">View property images</a>";
}
}
 
 
 
Basically, I want the user to search for a property, and...if they are not already logged in...log into their account, and then be able to return to the same property they were viewing without having to go through the search all over again. It makes the system more user-friendly.
The file bid.php allows the user to enter a bid value into the database. That doesn't work either, so I'm trying to work on one problem at a time...that is, redirecting the page after login.
bidprocess.php is an attempt at trying to show the property page after logging into the system.


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
khushbush
Forum Commoner
Posts: 99
Joined: Tue Mar 11, 2008 11:50 am

Re: Redirect page

Post by khushbush »

Erm...help? Please? It's kinda urgent... :?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Redirect page

Post by pickle »

Technically, we don't like bumping within 24 hours - you were really close though so it's ok this time ;)

The "Login to bid" button needs to pass along some information to your login page so the login page knows where to send the user after login. For example, you could make the link like this:

Code: Select all

<a href = "login.php?redirect_to=bid.php&redirect_id=1234">Login to bid</a>
Your login.php page could then access $_GET & send the user along to bid.php?id=1234 after a successful login.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
khushbush
Forum Commoner
Posts: 99
Joined: Tue Mar 11, 2008 11:50 am

Re: Redirect page

Post by khushbush »

Sorry :oops:
It's just that I've been pulling my hair over this problem for a week now...and it's been getting to me, cos I have very little time left, despite working so hard over this...

I will try out your method and see what I get...thanks for the swift reply :)
Post Reply