i put the functions on its own outside of the loop and when i go to run the page and view it.
the form on the page just keeps copying itself all the way down the page. i'm not sure whats going on with it.
how can i get the page to only display the form once and not have many copies of the form.
can someone please help?
here's the code i am using:
session_start();
require_once('bookmark_fns.php');
$username = $HTTP_POST_VARS['username'];
$passwd = $HTTP_POST_VARS['passwd'];
if ($username && $passwd)
{
if (login($username, $passwd))
{
$HTTP_SESSION_VARS['valid_user'] = $username;
}
else
{
do_html_header('Problem:');
echo 'You could not be logged in.
You must be logged in to view this page.';
do_html_url('login.php', 'Login');
do_html_footer();
exit;
}
}
$db_name = "database";
$table_name = "checkout";
$link_id = mysql_connect("localhost", "username", "password")
or die("Couldn't connect.");
$db = mysql_select_db($db_name, $link_id)
or die("Couldn't select database.");
mysql_query ("INSERT INTO $table_name (billfirstname, billlastname, billstreetaddr, billcity, billstate, billzipcode, billcountry, billcounty, email, phone, payment, creditnum, expire, questions, shipfirstname, shiplastname, shipstreetaddr, shipcity, shipstate, shipzipcode, shipcountry, shipcounty)
VALUES ('$billfirstname', '$billlastname', '$billstreetaddr', '$billcity', '$billstate', '$billzipcode', '$billcountry', '$billcounty', '$email', '$phone', '$payment', '$creditnum', '$expire', '$questions', '$shipfirstname', '$shiplastname', '$shipstreetaddr', '$shipcity', '$shipstate', '$shipzipcode', '$shipcountry', '$shipcounty')");
echo "$select<br>";
$host ="localhost";
$db_user="username";
$db_pass="password";
$database="database";
mysql_connect($host,$db_user,$db_pass);
mysql_select_db($database) or die ("Unable to select database");
echo "<center>Thank You For Shopping With Us!</center><br>";
echo "<center>";
check_valid_user();
echo "</center>";
echo "<br>";
echo "<center><a href='logout.php'>Click here to Logout</a></center>";
echo "<br>";
include("check.php");
echo "<br>";
echo "<strong>Your Billing and Shipping information!</strong>";
$query="SELECT * FROM $table_name WHERE billfirstname='$billfirstname' and billlastname='$billlastname' and billstreetaddr='$billstreetaddr' and billcity='$billcity' and billstate='$billstate' and billzipcode='$billzipcode' and billcountry='$billcountry' and billcounty='$billcounty' and email='$email' and phone='$phone' and payment='$payment' and creditnum='$creditnum' and expire='$expire' and questions='$questions' and shipfirstname='$shipfirstname' and shiplastname='$shiplastname' and shipstreetaddr='$shipstreetaddr' and shipcity='$shipcity' and shipstate='$shipstate' and shipzipcode='$shipzipcode' and shipcountry='$shipcountry' and shipcounty='$shipcounty'";
$result=mysql_query($query);
$num=mysql_numrows($result);
echo "<br>";
echo "the number of rows are: ";
echo $num;
echo "<br>";
function ret_upper_case($text){
$text = strtoupper($text);
return $text;
}
echo 'Just ', ret_upper_case('a quick return'), ' test';
function phonecheck($intext) {
$theresults = ereg("([0-9]{3})-([0-9]{3})-([0-9]{4})", $intext, $trashed);
if ($theresults) { $isamatch = ""; } else { $isamatch = "No - NOT A MATCH"; }
echo("\"$intext\" $isamatch<br>\n");
}
function ccnumcheck($intext) {
$theresults = ereg("([0-9]{16})", $intext, $trashed);
if ($theresults) { $isamatch = ""; } else { $isamatch = "No - NOT A MATCH"; }
echo("\"$intext\" $isamatch<br>\n");
}
function emailcheck($intext) {
$theresults = ereg("^[^@ ]+@[^@ ]+\.[^@ \.]+$", $intext, $trashed);
if ($theresults) { $isamatch = ""; } else { $isamatch = "No - NOT A MATCH"; }
echo("\"$intext\" $isamatch<br>\n");
}
function datecheck($intext) {
$result = ereg("([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})", $intext, $trashed);
if ($result) { $isamatch = ""; } else { $isamatch = "No - NOT A MATCH"; }
return "\"".$intext."\" ".$isamatch."<br>\n";
}
$result = mysql_query($query, $link_id);
while($query_data = mysql_fetch_row($result)) {
echo "<table>";
echo "<tr>";
echo "<td>billfirstname</td>";
echo "<td>",$query_data[0],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>billlastname</td>";
echo "<td>",$query_data[1],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>billstreetaddr</td>";
echo "<td>",$query_data[2],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>billcity</td>";
echo "<td>",$query_data[3],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>billstate</td>";
echo "<td>",$query_data[4],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>billzipcode</td>";
echo "<td>",$query_data[5],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>billcountry</td>";
echo "<td>",$query_data[6],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>email<br>";
echo "</td>";
echo "<td>",emailcheck("$email"),"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>phone</td>";
echo "<td>",phonecheck("$phone"),"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>payment</td>";
echo "<td>",$query_data[10],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>creditnum</td>";
echo "<td>",ccnumcheck($creditnum),"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>expire</td>";
echo "<td>",datecheck($expire),"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>questions</td>";
echo "<td>",$query_data[13],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>shipfirstname</td>";
echo "<td>",$query_data[14],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>shiplastname</td>";
echo "<td>",$query_data[15],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>shipstreetaddr</td>";
echo "<td>",$query_data[16],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>shipcity</td>";
echo "<td>",$query_data[17],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>shipstate</td>";
echo "<td>",$query_data[18],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>shipzipcode</td>";
echo "<td>",$query_data[19],"</td>";
echo "</tr>";
echo "<tr>";
echo "<td>shipcountry</td>";
echo "<td>",$query_data[20],"</td>";
echo "</tr>";
echo "</table>";
if(isset($_COOKIE['cartId'])) {
echo "<center><strong>----- cookie is set ----- </strong></center>";
}
else {
echo "<center><strong>----- cookie is NOT set ----- </strong></center>";
}
}