Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

oh no! how can I make a welcoming greeting in page

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

oh no! how can I make a welcoming greeting in page

Postby sarjanajava » Tue Jan 14, 2003 8:40 am

Dear Mr. Moderator
I have 3 codings as follow:
1)form.html---> asking user to LOGIN with username & password. This record stored in mySQL dbase: Login
2)loginsession.php---->to process what are user input in form.html and give a feedback
3)indexsession.php---->execute the page after username & password verified
<? my question is: How can i make a greeting in indexsession.php ,e.g :"welcome username, may involve $username for variable?
--------->
Here are that codings:
loginsession.php
Code: Select all
<?php
include("conf.inc.php");
if($HTTP_POST_VARS)
{
    $user=check_login($HTTP_POST_VARS["username"],$HTTP_POST_VARS["password"]);
    if($user)
    {
        $SESSION["user"]=$user;

        $goto="indexsession.php";
        redirect($goto);
        exit;
    }
else
{
    $errmsg="WRONG PASSWORD OR USERNAME";
     }
}
include("form.html");

//FUNCTION


function check_login($username,$password)
{
    $sql="SELECT * FROM ulogin WHERE username='$username' and password='$password'";
    $query=mysql_query($sql);
    return mysql_fetch_array($query);
}
?>

form.html
Code: Select all
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">


<html>
<head>
       <title>Login Page!</title>
</head>
<body bgcolor=#FFGHFF">
<center><?php echo $errmsg;

?></center>
<form method="post" action="loginsession.php">
<table width="50%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>username</td>
<td>
<input type="text" name="username">
</td>
 </tr>
 <td>Password</td>
 <td>
 <input type="password" name="password">
 </td>
 </tr>
 <tr>
 <td>&nbsp;</td>
 <td>
 <input type="submit" name="submit" value="submit">
 </td>
 </tr>
 </table>
 </form>
 </body>
 </html>

indexsession.php
Code: Select all
<!doctype html public "-//W3C//DTD HTML 4.0 //EN">

<html>
<head>
       <title>Title here!</title>
</head>
<body bgcolor="#FFFFFF">
<?PHP

echo("selamat datang $user");
?>
<table width="50%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td><a href="satu.php">satu.php</a></td>
</tr>
 <tr>
<td><a href="dua.php">dua.php</a></td>
</tr>
<tr>
<td><a href="logout.php">logout.php</a></td>
</tr>
</table>
</body>
</html>


THANK YOU[/quote]
User avatar
sarjanajava
New php-forum User
New php-forum User
 
Posts: 41
Joined: Wed Nov 27, 2002 10:59 pm

Postby Joan Garnet » Tue Jan 14, 2003 3:29 pm

Try to change this:
Code: Select all
$goto="indexsession.php?my_username=".$HTTP_POST_VARS["username"];

just echo the usrename in the indexsession.php page:
Code: Select all
echo "Wellcome ".$HTTP_GET_VARS["my_username"]."!";

I think this would be enough.
bye!
User avatar
Joan Garnet
Moderator
Moderator
 
Posts: 387
Joined: Sat Aug 03, 2002 2:56 am
Location: Mars

thanks

Postby sarjanajava » Tue Jan 14, 2003 9:37 pm

thanks for your advice :)
User avatar
sarjanajava
New php-forum User
New php-forum User
 
Posts: 41
Joined: Wed Nov 27, 2002 10:59 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 5 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.