how do i echo php code on html file
Posted: Wed Apr 21, 2010 5:57 am
Hello friends, I have a html form saved as join.html as below
and a php file saved as ckeck.php as below;
If any of the field is empty, I will be directed to check.php to see the error. I will want the error message to be echoed at the top of the form without be directed to the ckeck.php and without placing the php code on top of the form in join.html
Is this possible? if not which other option do i have?
regards
adsegzy
Code: Select all
<form id="form1" name="form1" method="post" action="check.php">
Name:
<label>
<input name="name" type="text" id="name" />
</label>
<p>Email:
<label>
<input name="email" type="text" id="email" />
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</p>
</form>
Code: Select all
<?php
if(!empty($_POST[Submit]))
{
$name=mysql_real_escape_string($_POST[name]);
$email=mysql_real_escape_string($_POST[name]);
if($name=="")
echo "Enter your Name.<br>";
elseif ($email=="")
echo "Enter your Email.<br>";
else
echo "Thank you.";
}
?>Is this possible? if not which other option do i have?
regards
adsegzy