This topic is locked

Edit Page: before process - Data capture issues

2/20/2009 7:30:16 AM
PHPRunner General questions
L
Lisa2006 author

Hi Forum,
I've set up the following code in Events | Edit Page: before process
echo "editid1 value is: " . $_REQUEST["editid1"] . "<br />";
global $conn, $strTableName;

$str = "select Fieldname1, Fieldname2, Fieldname3 from my_table where ID=".$_REQUEST["editid1"];

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);

echo "Session Email: " . $_SESSION["email"] . "<br />";

echo "Fieldname1 value is: " . $data["Fieldname1"] . "<br />";

echo "Fieldname2 value is: " . $data["Fieldname2"] . "<br />";

echo "Fieldname3 value is: " . $data["Fieldname3"] . "<br />";
if (($data["Fieldname1"]== '1') && ($data["Fieldname3"]==$_SESSION["email"])) {

header("Location: http://www.mywebsite.com/errpage1_list.php");

exit();

}
if (($data["Fieldname1"]== '1') && ($data["Fieldname3"]<>$_SESSION["email"])) {

header("Location: http://www.mywebsite.com/errpage2_list.php");

exit();

}
if (($data["Fieldname2"]== '1') && ($data["Fieldname3"]==$_SESSION["email"])) {

header("Location: http://www.mywebsite.com/errpage3_list.php");

exit();

}
if (($data["Fieldname2"]== '1') && ($data["Fieldname3"]<>$_SESSION["email"])) {

header("Location: http://www.mywebsite.com/errpage4_list.php");

exit();

}
Here's the problem

When a user logs in and simply enters the url below into the browser or via a link the values of Fieldname1, Fieldname2, Fieldname3 are not being pulled from the table 'my_table'. As a result the IF conditions cannot be carried out. By the way the S_SESSION["email"] is pulled from login and echoes correctly as does $_REQUEST["editid1"]
http://www.mywebsite.com/my_table_edit.php?editid1=895
Your help would be much appreciated.
Lisa

J
Jane 2/20/2009

Hi,
I suppose you need to check $_REQUEST["editid1"] before in your code and if it is empty do not execute this code.

L
Lisa2006 author 2/20/2009

Hi Jane,
When i simply enter the url into the broswer the correct $_REQUEST["editid1"] values in echoed ... therefore this is not empty or an incorrect value. Additionally, the record and all its field values are shown to the user.
How can i pull the values of Fieldname1, Fieldname2, Fieldname3 from table 'my_table' ????
Thanks in advance
Lisa

Sergey Kornilov admin 2/20/2009

As a first step - make sure you build correct SQL query. Pront SQL query on the web page and execute it in phpMyAdmin to see if it returns any data.
Here are some debugging tips:

http://www.xlinesoft.com/phprunner/docs/debugging_tips.htm