Board index   FAQ   Search  
Register  Login
Board index PHP PHP Scripts

A problem while passing vars thru query string

Links for php scripts

Moderators: macek, egami, gesf

A problem while passing vars thru query string

Postby sansoft » Wed May 12, 2004 4:48 am

hi all,

i have a mast_user table with 20 records......i have prepared a form which updates a particular record successfully......but something pinches me here......it updates username of the table and the user can assign the existing username to his record......

I mean i want to add a validation code which says "username already exists....please update with a different username if u really want to change"
but i cant figure out...where to add this...especially when the variables are sent by GET method.......ie passes thru querystring into the other file where GET_VARS are there.


i also dont want the common user to avoid changing the administrator details.....i mean how shud i do it.......the third file is coded by me as follows where update is executed....

plz help me.......out heres the third file......plz edit it

<?
include"../include/mysqlconnect.php";
$user_id=$HTTP_GET_VARS['userid'];
$user_name=$HTTP_GET_VARS['username'];
$user_pass=$HTTP_GET_VARS['password'];
$user_fname=$HTTP_GET_VARS['firstname'];
$user_lname=$HTTP_GET_VARS['lastname'];









$sql7="update mast_user set user_name='$user_name',user_pass='$user_pass',user_fname='$user_fname',user_lname='$user_lname' where user_id=$userid";




$result7=mysql_query($sql7,$conn);

if($result7)
{
echo("useraccount updated");
}



?>
sansoft
New php-forum User
New php-forum User
 
Posts: 44
Joined: Fri May 07, 2004 2:16 am
Location: India

Postby gesf » Wed May 12, 2004 11:18 am

Don´t forget... use GET/POST depending on your form method.
Using GET form method !? Try to use POST istead and $_GET/$_POST instead of $HTTP_*_VARS
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

Sorry but u have misunderstood my problem

Postby sansoft » Wed May 12, 2004 9:05 pm

Hi dear,

i did not get the related solution from u.........me thinks u have misunderstood mmy problem......plz read it carefully......i want only validation suggesstions from u......Anyways thanku very much for ur prompt response...............

plz help again!!!!!!

SAnsoft
sansoft
New php-forum User
New php-forum User
 
Posts: 44
Joined: Fri May 07, 2004 2:16 am
Location: India

Postby gesf » Wed May 12, 2004 10:15 pm

Well i saw you know and you´re already using the superglobals array e.g.: $_GET, $_POST, $_REQUEST ...

So what i wanted to say was:
If you are using the get method in your form, try using post method instead. And of course, in your php code use $_GET or $_POST depending on it.

And in last case to use the same $_GET or $_POST in your php code, instead of $HTTP_GET_VARS or $HTTP_POST_VARS!
User avatar
gesf
Moderator
Moderator
 
Posts: 1717
Joined: Sun Dec 29, 2002 5:03 am
Location: Portugal / Sweden

thanks!!

Postby sansoft » Thu May 13, 2004 3:39 am

Hi all,

thank u very much....problem solved at last....Hats off to you alll....i really mean it................

Sansoft
sansoft
New php-forum User
New php-forum User
 
Posts: 44
Joined: Fri May 07, 2004 2:16 am
Location: India


Return to PHP Scripts

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest

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