Jump to content

[SOLVED] Can some one help with this error?


herghost

Recommended Posts

if ($step=="signup7") {

//title
echo "<h2>Primary Contact Information</h2>";
echo "This is how your business will be contactable through the site, so customers know where to bring their coupons! You can add addresses for 
more locations later";

//get user value from session
$cur_business = $_SESSION["cur_business"];

//Post Variables
$address1= trim($_POST ["address1"]);
$address2= trim($_POST ["address2"]);
$country = trim($_POST["country"]);
$city= trim($_POST ["city"]);
$state= trim($_POST ["county"]);
$zip= trim($_POST ["postcode"]);
$phone1= trim($_POST ["phone1"]);
$phone2= trim($_POST ["phone2"]);
$fax= trim($_POST ["fax"]);
$email= trim($_POST ["email"]);


////////////////
//form checking 
///////////////
if ($_POST) {

	$error=":</b>";
	//Check for primary in DB (dont let people add 2)
	db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]);
	$sql = "select * from contacts where business='$cur_business' and pri_contact=1";
	$result = db_query ($sql);
	while ($row=mysql_fetch_object($result)) {
	$id = $row->business;
	}
	mysql_close();
	if ($id!="") {$error.="Primary Address Already Entered, <A href=index.php?page=signup8>Proceed to next step </a>";}


	//make sure address1 was entered
	if ($address1=="") {$error.="Address Line 1 Not Entered. ";}
	//make sure city was entered
	if ($city=="0") {$error.="City Not Selected. ";}
	//make sure state was entered
	if ($state=="0") {$error.="County Not Selected. ";}
	//make sure country was entered
	if($country=="0") {$error.="Country Not Selected";}
	//make sure zip was entered
	if ($zip=="" || strlen($zip)<6) {$error.="Postcode Not Entered  ";}
	//make sure zip were entered
	if ($phone1=="") {$error.="Phone Number Not Entered. ";}

	//make sure username is a valid formatted email addres
	if (checkEmail($email)==0 && $email!="") { $error.="Email is not a real email address.";} 

	//Pull out city and state values
	db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]);

	$sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state=$state and c.city=$city and co.country=$country";

	$result = db_query ($sql);

	while ($row=mysql_fetch_object($result)) {

		$state = $row->sabbr;

		$city = $row->cty_name;

		$country = $row->cabbr;

	}

	mysql_close();


	//Print error, or redirect to next step
	if ($error!=":</b>") {

		echo "<Br><b> The Following Problems were found $error <br>";
		unset($_POST);

	} else {

		echo "<Br>Saving contact Info Record Number: ";

		//Insert 
		db_connect ($cfg["db_server"], $cfg["db_user"], $cfg["db_pass"], $cfg["db_database"]);
		$values = "$cur_business,'$address1','$address2','$city','$state','$zip','$phone1','$phone2','$fax','$email','$country',1";
		$cols = "business,address1,address2,city,state,zip,phone1,phone2,fax,email,county,pri_contact";
		$id = db_insert ("contacts", $cols, $values);
		mysql_close(); 
		echo "$id";
		redirect ("index.php?page=signup8");
	}

}

//////////////
//form
//////////////
if (!$_POST) {
	echo "<form name=contact method=post action=index.php?page=signup7>";
  	echo "<input type=text name=address1 value='$address1'> <b> Address Line 1 </b> *<br>";
  	echo "<input type=text name=address2 value='$address2'> <b> Address Line 2 </b> <br>";
	$formname="contact";include("citystate.php");
  	echo "<Br><input type=text size=11 maxlength=10 name=zip value='$zip'> <b> Postcode </b> * <br>";
  	echo "<input type=text name=phone1 value='$phone1'> <b> Phone 1 </b> * <br>";
  	echo "<input type=text name=phone2 value='$phone2'> <b> Phone 2 </b> <br>";
  	echo "<input type=text name=fax value='$fax'> <b> Fax </b> <br>";
  	echo "<input type=text name=email value='$email'> <b> Email </b> <br>";
  	
  	echo "<Br><input type=submit value='Proceed to Login'>";

	echo "</form>";
}

}

Link to comment
Share on other sites

Change these lines

 

$sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state=$state and c.city=$city and co.country=$country";
$result = db_query ($sql);

 

To

$sql = "select *, s.abbr as sabbr, co.abbr as cabbr from cities c,states s,countries co where s.state='$state' and c.city='$city' and co.country='$country'";
$result = db_query($sql)or die(mysql_error() .'<p>QUERY: '.$sql);

 

Post any errors you get.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.