PHP - how do i echo php code on html file - Asked By Olusegun A. on 21-Apr-10 06:59 AM

Hello friends, I have a html form saved as join.html as below

<form id="form1" name="form1" method="post" action="check.php">

<input name="name" type="text" id="name" />
<input name="email" type="text" id="email" />
<input type="submit" name="Submit" value="Submit" />

and a php file saved as ckeck.php as below;


echo "Enter your Name.<br>";
elseif ($email=="")
echo "Enter your Email.<br>";
echo "Thank you.";


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?

Santhosh N replied to Olusegun A. on 21-Apr-10 07:19 AM
You could actually do that in javaascript before submitting to php page...
Ideally you can use onclientclick and validate the inputs before submitting tio the server side code which is php..

Make sure to return true on successful validation in javascriopt and false for not validating so that it will not be submitted