Click to See Complete Forum and Search --> : return values to page


Taffy
March 1st, 2006, 04:21 AM
I have a login page i made. I want when the user clicks summit the data to be processed and a return value given to the original page if the pasword or username are wrong, so, this is pre_reg.php

<code><FORM action=register.php method=post>

<INPUT class=table_text
name=username>
<INPUT class=table_text
type=password name=password>
<INPUT type=image height=20
width=94
src="btn_register_green.gif"
align=top value=Submit border=0 name=Submit22>
</FORM></code>

I process these values in register.php, well i want to return either , registration ok or invalid to this page so i could insert a php script in this such as,

<code>
<html>
<body>

<?php

$theresult = $_GET['result'];

if($result =="invalidpass"){

echo "Invalid Password";

}elseif($result =="invaliduser"){

echo "Invalid username";
}

?>

<FORM action=register.php method=post>

<INPUT class=table_text
name=username>
<INPUT class=table_text
type=password name=password>
<INPUT type=image height=20
width=94
src="btn_register_green.gif"
align=top value=Submit border=0 name=Submit22>
</FORM></code>

and in my register.php i would have,


<code>if(!empty($result)){

$link = mysql_query("select password from tlogin where password = '".$password."' LIMIT 1");

$result = mysql_fetch_row($link);

if(empty($result)){

Header("Location: login.php?result=invalidpass");

}else{

Header("Location: main.php");

}

}else{

Header("Location: login.php?result=invaliduser");

}</code>

this all works fine apart from when you load the page in the first place, as there is no query string just register.php so hence i get an error echoed where the invaild password or invalid username would be saying unknow index result.

How would i get around this, i just need to avoid this error being displayed on the page?

PeejAvery
March 1st, 2006, 07:18 AM
You need to disable the error display with the @.

Change...
$theresult = $_GET['result'];
To...
$theresult = @$_GET['result'];

degsy
March 7th, 2006, 05:57 AM
or use isset to check if the variable has been set.