Posting

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
kevinks
Forum Newbie
Posts: 8
Joined: Thu Feb 21, 2008 2:30 pm

Posting

Post by kevinks »

Hello guys.
Got stuck while trying to post am input value
LEt me try to explain it

i've got my login page(index.php) where u input an ID('cust_id') and a password(name='pass') [form method='post' and action='front_login.php']. On submit, these input data is send to a front_login.php page for validation purposes n md5 encryption and this data is checked against the contents of my database.

Once access is granted, the user is redirected to main.php.

My question is HOW can i display on main.php " WELCOME user 'ID'"

I mean i already put action= 'front_login' how can i post the cust_id to main.php?

Hope i get an answer,
thanking you in advance :)
User avatar
liljester
Forum Contributor
Posts: 400
Joined: Tue May 20, 2003 4:49 pm

Re: Posting

Post by liljester »

this looks like a job for Sessions.

basically during your login process you will need to create some session variables to keep track of the user info, like ID. its very easy.

Code: Select all

$_SESSION['cust_id'] = $_POST['cust_id'];
then from any of your pages from then on, the session variable $_SESSION['cust_id'] should be available to your script until:
1) you destroy the session with session_destroy()
2) the session time out expires (setting in php.ini)
3) the user closes thier browser (wich kills the session on the users end)
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Posting

Post by califdon »

liljester wrote:this looks like a job for Sessions.

basically during your login process you will need to create some session variables to keep track of the user info, like ID. its very easy.

Code: Select all

$_SESSION['cust_id'] = $_POST['cust_id'];
then from any of your pages from then on, the session variable $_SESSION['cust_id'] should be available to your script until:
1) you destroy the session with session_destroy()
2) the session time out expires (setting in php.ini)
3) the user closes thier browser (wich kills the session on the users end)
But don't forget the crucial requirement: every script that either writes or reads session variables must have this line in it before you can do any session stuff:

Code: Select all

session_start();
kevinks
Forum Newbie
Posts: 8
Joined: Thu Feb 21, 2008 2:30 pm

Re: Posting

Post by kevinks »

Mod | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello thx 

But am using cookie :-p
Its not the same as session i mean then syntax part

front_login.php

Code: Select all

<?php
require_once('library/conn1.php');
 
$id = 0;
$pwd=$_POST["password"];
$encryptedpwd = md5($pwd);
$code =$_POST["cust_id"];
 
$sql = "SELECT * FROM customer WHERE password='".$encryptedpwd."' AND cust_id='".$code."'";
 
$result = QueryToTable($sql);
 
if (count($result)>0) {
    $id = $result[0]->cust_id;
}
 
$ret=setcookie("TestCookie", $id, time()+3600);
 
if ($ret==FALSE){
    echo "Error setting cookie. check your browser settings. Enable cookies to view pages correctly!";
    exit;
}
if ($id > 0) {
    echo '<h2 align=center>Customer '.$_POST["cust_id"].' click <A href=main.php>here</a> to enter..</h2>';
} else {
    echo '<h2 align=center><a href=index.php>Try Again</a></h2>';
}
 
?>

What is the syntax for displaying cust_id in another page?
Thx :)


Mod | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
kevinks
Forum Newbie
Posts: 8
Joined: Thu Feb 21, 2008 2:30 pm

Re: Posting

Post by kevinks »

Guys i fink i found out abt the cookie fing :wink:

i just had to put "<?php print "$_COOKIE[TestCookie]"; ?>" :lol:

Thx
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Posting

Post by Jonah Bron »

Not quite, but close:

Code: Select all

<?php
echo $_COOKIE['TestCookie'];
?>
kevinks
Forum Newbie
Posts: 8
Joined: Thu Feb 21, 2008 2:30 pm

Re: Posting

Post by kevinks »

yes :) thx
kevinks
Forum Newbie
Posts: 8
Joined: Thu Feb 21, 2008 2:30 pm

SMS Support

Post by kevinks »

Hello guys, i need your help once again :D

Am actually trying to develop a system which has an SMS support.
My system will send sms to people. I attached my mobile phone to my laptop, and i have to write php codes so that when an action is perform, i.e assume that when X=1, send an sms to people X.

I have been looking on the net, havent seen it. If u got somefing for me, just let me no,
thanking u in advance, cheers!
Post Reply