Jump to content

Text Box If Statement


jarrett000

Recommended Posts

Code:

<?php$name=$_GET['name'];if (!isset($name))echo "<form><input type="text" name="name" /></form>";else if (isset($name))echo "Welcome $name!";?>

Problem: This works fine, is extremely simple, and took me less than a minute to do. But what I want to have done if a certain value is typed into the box it will display different results.I've been over different ways to do this on my own, and with the assistance of a friend but I simply do not know the correct if statement (if one exists).I've tried: I have attempted this with a simple guess statement (it disen't work of course):

if ($name="Password") {$time=time()+10 { setcookie("name", Jarrett, $time); }}

Does anyone know the CORRECT statement to do this?

Link to comment
Share on other sites

The single equals sign is the assignment operator, if you want to compare two values for logical equality use ==.Don't know what is with the double curly braces either...

if ($name == "Password") {	$time=time()+10;	setcookie("name", Jarrett, $time);}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...