Need Some Help here

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
Razael
Forum Newbie
Posts: 7
Joined: Fri Jul 12, 2002 8:00 pm

Need Some Help here

Post 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!?
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

be more specific please :)
User avatar
harsha
Forum Contributor
Posts: 103
Joined: Thu Jul 11, 2002 1:35 am
Location: Bengaluru (Bangalore) > Karnataka > India

so do like this

Post 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
Razael
Forum Newbie
Posts: 7
Joined: Fri Jul 12, 2002 8:00 pm

Post by Razael »

Thanks a lot man.
Razael
Forum Newbie
Posts: 7
Joined: Fri Jul 12, 2002 8:00 pm

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Razael
Forum Newbie
Posts: 7
Joined: Fri Jul 12, 2002 8:00 pm

Post by Razael »

Thanks alot guys your help was very useful. Now my script does what I wanted. :)
Post Reply