Jump to content

Form validation on same page


Vink
 Share

Recommended Posts

Hi!I have a comment script with a validation that appears on a new page...I can't understand what to alterto appear it on the same page as the form..here is the form:comment scriptand here the validation:

function smcom_check_for_errors() {	global $comments_db_link, $COM_CONF, $COM_LANG;	$ip = mysql_escape_string($_SERVER['REMOTE_ADDR']);	$result = mysql_query("SELECT ip FROM {$COM_CONF['dbbannedipstable']} WHERE ip='$ip'", $comments_db_link);	if (mysql_num_rows($result)>0) {		$error_message.=$COM_LANG['not_allowed'] . "<br />";	}	if ($_REQUEST['disc_name'] == '') {		$error_message.=$_REQUEST['r_disc_name'] . "<br />";	}	if ($_REQUEST['disc_body'] == '') {		$error_message.=$_REQUEST['r_disc_body'] . "<br />";	}	if ($_REQUEST['disc_email'] != '') {		if (!smcom_is_email($_REQUEST['disc_email'])) {			$error_message.="Invalid email address" . "<br />";		}	}echo ' <script language = "javascript"> alert("Vul s.v.p. alle velden in")</script>'; 	//return $error_message;}

and here the form

 <form method=POST action='{$COM_CONF['script_url']}'>				  <input type=hidden name="action" value="add">			  <input type=hidden name="href" value="{$_SERVER['REQUEST_URI']}">		  <table width="290" border="0" cellspacing="1" cellpadding="2" align="left">			<tr> 			  <td width="83" align="right"><font color="red" >*</font><font size=2>{$COM_LANG['Name']}:</font>				</td>			  <td width="196" align="left">				<input type=text name="disc_name" maxlength=40 size=30>				<input type=hidden name="r_disc_name" value="{$COM_LANG['r_disc_name']}">				</td>			</tr>			<tr> 			  <td width="83" align="right"><font size=2>{$COM_LANG['E-mail']}:</font></td>			  <td width="196" align="left">				<input type="Text" name="disc_email" size="30" maxlength="70">				</td>			</tr>			<tr> 			  <td width="83"></td>			  <td width="196" align="left">			<input type="checkbox" name="email_me"><font size=2><nobr>{$COM_LANG['Notify']}</nobr></font><br>			<input type="checkbox" name="dont_show_email" CHECKED><font size=2><nobr>{$COM_LANG['Dont_show_email']}</nobr></font><br>				</td>			</tr>			<tr> 			  <td valign="top" width="83" align="right"> 				<font color="red">*</font><font size=2>{$COM_LANG['Text']}:</font>			  </td>			  <td valign="top" width="196" align="left">				<textarea name="disc_body" cols="40" rows="13" wrap="VIRTUAL"></textarea>				<input type=hidden name="r_disc_body" value="{$COM_LANG['r_disc_text']}">				</td>			</tr>			<tr> 			  <td valign="top" width="83" align="right">  </td>			  <td valign="top" width="196">				<div align="center">				  <input type="submit" name="Submit" value="{$COM_LANG['Submit']}">				  </div>			  </td>			</tr>		  </table>		</form>

Das enyone knows how to do that?regardsParis

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...