Page 1 of 1

Need Some Help here

Posted: Wed Aug 07, 2002 11:11 pm
by Razael
OK, im trying to do a script that throug a form inserts some data to MySQL

I want when i

Code: Select all

If($name=="whateverusertypes")
I want to set that variable so the script accepts all names that are submited.

How can i solve my problem

Also can I put more tha two variable in a "IF" Statement and how!?

Posted: Thu Aug 08, 2002 12:04 am
by fatalcure
be more specific please :)

so do like this

Posted: Thu Aug 08, 2002 1:11 am
by harsha
you have a form code like this
<input type="text" name="fname">

here name="name"

ie., name is a variable $name
or HTTP_POST_VARS['name']

use this to add directly

if(!empty($name))
{
do this ;
}
else if(empty($name))
exit;
}


you can also include multiple variable

say all the feilds are compulsory

then use

if(!empty($name)&&!empty($email))
{
}

either of one use this || or symbol

thatz all

Posted: Thu Aug 08, 2002 7:16 pm
by Razael
Thanks a lot man.

Posted: Thu Aug 08, 2002 11:36 pm
by Razael
ok i still have some problems in my code, im a newbie at this so please help me.

Code: Select all

<?php
if(!empty($nick) && !empty($review))
&#123;
	$db = mysql_connect("localhost","user","pass");
	$dbselect = mysql_select_db("test",$db);
	$query = "create table data(nick,review) values('"$nick","$review"')";
	$result = mysql_query($query);
&#125;
elseif($dbselect == false && $result == false)
&#123;
	echo("Did not connect to Database<br>\n");
	echo("Query Failed");
&#125;
else($dbselect == true && $result == True)
&#123;
	echo("Operation succsesfully done");
&#125;
?>
I want that te variables $nick and $review be What ever the users type in the form, and then be inserted into de MySQL table so they can be acceced later.

But when I hit submit the script does nothing, can anyone enlighten me? or explainme whats going wrong. Thanx

Posted: Fri Aug 09, 2002 2:27 am
by twigletmac

Posted: Sat Aug 10, 2002 2:01 pm
by Razael
Thanks alot guys your help was very useful. Now my script does what I wanted. :)