This topic is locked

Page Redirects

10/19/2005 9:00:09 AM
PHPRunner General questions
H
HurricanHollow author

I have a user registration page for all visitors to the site (No Login) but would like to redirect them to the printer friendly page showing the record they just added.
Is there an easy way to accomplish this?

Sergey Kornilov admin 10/20/2005

Hi,
you can modify generated register.php file to redirect user to the particular View page. This is quite easy if you are familiar with PHP programming.
Here is the place where you can put your code. Please see my changes in bold.

 $registered=true;

 $onload="";
 $_SESSION["UserID"]=$strUsername; // this will log in as a newly registered user
 .... // put your code to determine the URL for a View page here
 header("Location: ..._view.php?editid=...");

 return;

}

}

H
HurricanHollow author 10/20/2005

Hi,
Sorry I was not clear.
I have the project setup to direct the user to the ShowCaseEntry_add.php page without logging them in (No login or php program registration needed here).
I also know how to redirect them to the printer friendly page once they complete the form...then press the Save button.
What I would like to do is to have the record that they just added & saved and no other records show in the printer friendly page for printing and mailing to us.
Thanks for your help
Jon

Sergey Kornilov admin 10/21/2005

Jon,
I see what you saying.
To make printer-friendly page show a desired subset of records only you should put SQL query to return this rowset into $_SESSION["yourtable_sql"].
i.e. put the following line before redirecting to Printer-friendly page:

$_SESSION["yourtable_sql"] = "select * from yourtable where id=$id";



where yourtable is your actual case-sensitive table name.

H
HurricanHollow author 10/21/2005

Hi Sergey,
In my ..add.php code and after:
$message="<div class=message><<< "."Record was added"." >>></div>";
I have placed the following code, email seems to work fine.....
[QUOTE]ini_set("sendmail_from", "entry@mywebsite.com");

mail( $_POST["value".array_search("email",$fieldlist)],

"type your subject here",

"type message text here");

?>

<script>
$_SESSION["ShowCaseEntry_sql"] = "select * from ShowCaseEntry where id=$id";
window.location="http://www.mywebsite.com/ShowCaseEntryForm/Code/ShowCaseEntry_print.php";;
</script>

<?php

return;
Page cannot be displayed and I am getting two errors:

  1. Error: Expected ')' on line 490
  2. Error: Expected 'SESSION' is undefined on line 548
    Thanks

Sergey Kornilov admin 10/24/2005

Hi,
you should put

$_SESSION["ShowCaseEntry_sql"] = "select * from ShowCaseEntry where id=$id";



inside <?php ... ?>tags. I.e. just after a call to mail() function.