Page 1 of 1

Posting

Posted: Thu Feb 21, 2008 2:40 pm
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 :)

Re: Posting

Posted: Thu Feb 21, 2008 2:51 pm
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)

Re: Posting

Posted: Thu Feb 21, 2008 10:21 pm
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();

Re: Posting

Posted: Fri Feb 22, 2008 3:12 am
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]

Re: Posting

Posted: Fri Feb 22, 2008 3:32 am
by kevinks
Guys i fink i found out abt the cookie fing :wink:

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

Thx

Re: Posting

Posted: Fri Feb 22, 2008 11:03 am
by Jonah Bron
Not quite, but close:

Code: Select all

<?php
echo $_COOKIE['TestCookie'];
?>

Re: Posting

Posted: Fri Feb 22, 2008 11:07 am
by kevinks
yes :) thx

SMS Support

Posted: Fri Mar 07, 2008 9:35 am
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!