Echo Messages

this weeks task was to make the form post to the page

Screen Shot 2015-01-08 at 12.42.52

 

we done this in two parts;

first

$query = “INSERT INTO users (name, description, city, gender) VALUES (‘{$name}’, ‘{$description}’, ‘{$city}’, ‘{$gender}’)”;    <!–this tells the computer to insert the given information, in the variables, into the data base–>

$result = mysquli_query($connect, $query);    <!– this is creating a new variable that is built around “$connect” and “$query” –>

if($result){   <!– this is saying that when there is a result…–>

$message = “Successful”;   <!– a message will show saying “Successful to let the user know they may proceed” –>

} else{   <!– however if there is no result –>

$message = “Unsuccessful”;   <!– then a message will show saying Unsuccessful to let the user know they encountered a problem” –>

}

and secondly,

<?php    <!– before the user can be made aware of any possible problems the computer must know that it needs to tell the user something–>

if(isset($message)){    <!– this is saying that if is true that there is a variable set to “$message”…–>

echo $message;    <!–then show what is in the variable  –>

}

?>

<p> Name: <?php echo $name; ?> </p>    <!– these four lines are posting either name, description, city or gender with whatever the user has given the variable –>

<p> Description: <?php echo $description; ?> </p>    <!– –>

<p> City: <?php echo $city; ?> </p>

<p> Gender:<?php echo $gender; ?> </p>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: