CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Posts
    19

    return values to page

    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?

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: return values to page

    You need to disable the error display with the @.

    Change...
    PHP Code:
    $theresult $_GET['result']; 
    To...
    PHP Code:
    $theresult = @$_GET['result']; 
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Dec 2005
    Posts
    62

    Re: return values to page

    or use isset to check if the variable has been set.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured