0

Hi. I just wonder, is it possible, to validateform , which has been "echoed" in PHP using JavaScript function?
See code below

<?php 
if(isset($_SESSION['email'])){

echo"You are looged in as ".$_SESSION['email']. "</br> ";  
echo' <form action="confirmlogout.php" id"logoutform" method="post">
<input type="submit"id="sub" name="sub" onclick="" value = "LOG OUT" />
</form></br>';
}
else{

echo '<h3>Please fill up registration form, to create user account</h3>
<form action="signup.php" id="signform" method="POST" onSubmit="validate()">
<ul>
<li>Please enter your first name: &nbsp;<input type="text" id="fname" name="fname" autofocus autocomplete="" /><div id="erfname"></div></li>
<li>Please enter your last name: &nbsp<input type="text" id="lname" name="lname" onFocus="validate()" /><div id="erlname"></div></li>
<li>Please enter your flat number: &nbsp<input type="text" id="hno" name="hno" /><div id="erfno"></div></li>
<li>Please enter your house number: &nbsp<input type="text" id="hno" name="hno" /><div id="erhno"></div></li>
<li>Please enter street name: &nbsp<input type="text" id="street" name="street" /><div id="erstreet"></div></li>
<li>Please enter your postcode: &nbsp<input type="text" id="pcode" name="pcode" /><div id="erpcode"></div></li>
<li>Please enter your email address: &nbsp<input type="email" id="email" name="email" /><div id="eremail"></div></li>
<li>Please create your password: &nbsp<input type="password" id="pwd1" name="pwd1" /><div id="erpwd1"></div></li>
<li>Please repeat your password: &nbsp<input type="password" id="pwd" name="pwd" /><div id="erpwd"></div></li>
</ul>
<input type="submit" id="submit" name="submit" onSubmit="validate()" value = "Submit" />

</form>
  <a href="log_in.php">Or log in, if you are already registered</a>';
}
?>
3
Contributors
3
Replies
31
Views
3 Years
Discussion Span
Last Post by wkwasniak
0

Yes, sure. I dont see why. When you access this page, the PHP engine converts it to html markup and sends it back to the browser. So I dont see why the concern about the PHP echo'ing.

0

I must add as well, make sure you're not relying solely on javascript for your data validation. It should really only be used for user experience and that is all. Always do your final data validation server side with PHP.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.