Can someone let me know if I have something wrong.
index.php
insertlead.phpPHP Code:<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Call Log</title>
</head>
<body>
<?php
$error = $_SESSION['error'];
if($error == 1)
echo "<p>Lead already called.</p>";
else
echo "";
?>
<form name='start_call' action='insertlead.php' method='post'>
<table>
<tr>
<td valign='top'>Company Name<br /><input type='text' name='company' /></td>
<td>Company Phone<br /><input type='text' name='phone' /></td>
</tr>
<tr>
<td><input type='submit' value='Insert Lead' /></td>
</tr>
</table>
</form>
<p><a href="startcalls.php">Start Calls</a></p>
</body>
</html>
The script catches the duplicate phone number but does not set the error.PHP Code:<?php
session_start();
$phone = $_POST['phone'];
$company = $_POST['company'];
$phone = preg_replace("![^0-9]!", "", $phone);
** Database Connection **
$query = "SELECT phone FROM call_log";
$result = mysql_query($query)
or die ("Couldn't query data" . mysql_error());
$row = mysql_fetch_array($result);
if($phone == $row['phone']) {
$_SESSION['error'] = 1;
echo "<script type='text/javascript'>
<!--
window.location = 'index.php'
//-->
</script> ";
}
else {
mysql_query("INSERT INTO call_log (company, phone) VALUES ('$company', '$phone')");
echo "<script type='text/javascript'>
<!--
window.location = 'index.php'
//-->
</script> ";
}
?>


Reply With Quote

Bookmarks