I must now seek help after too many hours of failure.

I'm using a basic form with Ajax (prettyPopin), but the form is not connecting to the database. I'm obviously overlooking something.

Here is the basic form:


<h3>Retailer Contact</h3>
<form name="ajaxForm" action="ajax/form_submit.php" method="post" class="genericForm">
<label><span>* Full name</span>
<input type="text" name="full_name" id="full_name" class="input-text"/>
<label><span>* Email</span>
<input type="text" name="email" id="email" class="input-text"/>
<input name='submit' type='submit' class='button' value='register' style='height:20px; color:#444; width:80px;'>

Here is the php page the form calls:


<h3>Subscribe to our<br />newsletter</h3>


require( 'config.php' );

$con = mysql_connect( $mySQLhost,$mySQLuser,$mySQLpass ) or die( 'Error: ' . mysql_error() );
mysql_select_db( $mySQLdb );

	$hasError = false;
	$nameError = false;
	$emailError = false;
	if($_POST['full_name'] == ""){
		$hasError = true;
		$nameError = true;
	if($_POST['email'] == ""){
		$hasError = true;
		$emailError = true;
	if(!eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.([a-zA-Z]{2,4})$', $_POST['email'])){
		$hasError = true;
		$emailError = true;
	if($hasError){ ?>
	<form name="ajaxForm" action="ajax/form_submit.php" class="genericForm">
		<label for="name">Name</label>
		<input type="text" name="name" id="name" value="<?php echo $_POST['full_name'] ?>" />
		<?php if($nameError){ ?><div class="error-message">Please enter your name.</div><?php } ?>
		<label for="email">Email</label>
		<input type="text" name="email" id="email" value="<?php echo $_POST['email'] ?>" />
		<?php if($emailError){ ?><div class="error-message">Please enter a valid email.</div><?php } ?>
		<input type="submit" value="Submit" class="submit" />
	<?php }else{ ?>
		<p><small>Thank you, the form has been successfully submitted!</small></p>
	<?php } ?>

I get no database errors. The form will be more substantial, but I can't get it to work with these two fields. Any suggestions? Any help? Thanks very much...

7 Years
Discussion Span
Last Post by theighost

hmm, i don't see any ajax function that adds to the database, it seems u overlooked to mention it, or might i be mistaken.

This article has been dead for over six months. 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.