error message

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
revbackup
Forum Commoner
Posts: 29
Joined: Tue Jun 09, 2009 1:52 am

error message

Post 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
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: error message

Post 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.
revbackup
Forum Commoner
Posts: 29
Joined: Tue Jun 09, 2009 1:52 am

Re: error message

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: error message

Post 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"...
Post Reply