Page 1 of 1

error message

Posted: Wed Jul 15, 2009 10:31 pm
by revbackup
hi,

I have a sign in page, and If the sign in is unsuccessful, it should display the error
message in the same page.... How will I do that? I have my codes here:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Login</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
 
<body  background="rPanel/Sun-anan/vvltgrayparch.jpg" >
<center><font face="Arial Narrow">
<form name="login" method="post" action="signin.php">
    <p>&nbsp;</p>
    <p>&nbsp; </p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <?php
     
    $errormessage = $_SESSION['errormessage'];
    echo $errormessage;
    ?>
    <table width="10%" border="7"  bordercolor="#339966" cellspacing="0" cellpadding="0" align="center">
  <tr>
        <td colspan="2" align="center" > <img  src="buttons/btn4.jpg" width="212" height="31"></td>
    
  </tr>
  <tr>
    <td>username:</td>
    <td>  <input type="text" name="username">
  </tr>
  <tr>
    <td>password:</td>
    <td>  <input type="password" name="password">
  </tr>
    <tr>
        <td colspan="2" align="right" background="rPanel/Buttons/btn2.jpg" ><div align="center"><font face="Arial Narrow"> 
            <input type="submit" name="Submit" value="Submit">
            </font> </div></tr>
 
</table>
</form>
 
  <p><font color="#000000" size="+1">Create your account <a href="signup.php" target="_blank">here</a>.</font></p>
  </font>
  <p>&nbsp;</p>
  <p><font color="#000000" size="+1"><br>
    <font face="Arial Narrow">Upload your IT Projects instantly!<br>
    <a  href="procedures.php"target="_blank"> Here's</a> how. </font></font></p>
  <p> 
</center>
</body>
</html>
 
 

and this is signin.php

Code: Select all

<?php
    session_start();
    include "dbconnection.php";
    mysql_select_db("itproject",$link);
    $_SESSION['uname'] = $_POST['username'];
    $_SESSION['pass'] = $_POST['password'];
    
    if($_SESSION['uname']=="" || $_SESSION['pass']=="")//y gi.input
    {
        echo ("<meta http-equiv='Refresh' content='0;url=index.php'>");
        $errormessage = 'Please put something on the fields.';
    }
    
    else{
            $result = mysql_query("SELECT * FROM pending WHERE gid='".$_SESSION['uname']."' AND password='".$_SESSION['pass']."'");
            $number = mysql_num_rows($result);      
                    
                    if($number!=0)
                    {
                        echo ("<meta http-equiv='Refresh' content='0;url=multiple_upload.php'>");
                    }
                    
                    else 
                    {
                        $errormessage = "Wrong username or password.";                  
                        echo ("<meta http-equiv='Refresh' content='0;url=index.php'>");
                        
                    }
        }
?>
 

Please correct my codes.... thanks... :D

Re: error message

Posted: Wed Jul 15, 2009 10:42 pm
by Eric!
Looks like you forgot to set $_SESSIONS['errormessage']='your message'; in your php code....

Also you need a session_start around line 18 in the first set of code.

Re: error message

Posted: Wed Jul 15, 2009 10:47 pm
by revbackup
hi,

can you erase [in my code] what needs to be erased and add what needs to be added,
because I don't really have the idea how to do that...
I am new in php...

if it's ok for you to spoonfeed me with the codes, it would be great....

thanks very much... as in.... :D

Re: error message

Posted: Thu Jul 16, 2009 12:16 am
by requinix
revbackup wrote:if it's ok for you to spoonfeed me with the codes, it would be great....
No. It's not. Because if we do you'll never learn, and that means you'll keep coming back to us every time you have a little problem.

He told you what you need to do. If you can't understand something as simple as "you need a session_start around line 18"...