Moderators: macek, egami, gesf




MissTortoise! wrote:There are actually not Real codes.



<?
include("db.php");
$link=dbconnect();
if(isset($_POST['mailing2'])){
$query="SELECT * from Customer WHERE CustEmail='".$_POST['email']."';";
$result=safe_query($query);
if(!(mysql_num_rows($result))){
$query="INSERT INTO Customer(eid,CustName,CustCountry,CustTailor,CustEmail,regDate,Custrecomm,Custcomment)
VALUES('','".$_POST['name']."','".$_POST['country']."','".$_POST['field']."','".$_POST['email']."',now(),'".$_POST['recommendation']."','".$_POST['commentbox']."');";
safe_query($query);
$message="We have received your review. Thank you very much. We hope to give you better services through this. Please click <a href=http://www.hst.com.sg title="Welcome to Hwa Seng Textiles Online Fabric stores"> here</a> to go back to home page.";
}else{
$message="Sorry, We are unable to receive your Review. Please click <a href="http://www.hst.com.sg/acatalog/Business.html" title="You are now in Hwa Seng Online Fabric stores -Please try again. Thank you"> here</a> to enter another email address. If it still doesn't work, please contact us at, (65)63455154 or <a href="mailto:hstextile@hst.com.sg" title="Online Fabric stores">Email us</a>.";
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?=$message?>
</body>
</html>

mysql_query($query) or die(mysql_error());
if(isset($_POST['mailing2'])){
$query="SELECT * from Customer WHERE CustEmail='".$_POST['email']."';";
$result=mysql_query($query) or die("Query one error: ".mysql_error());
//If no record found.The one you have used before would work in case there was an error in mysql_num_rows() excecution. No rows is NOT an error
if(mysql_num_rows($result)==0){
$query="INSERT INTO Customer(eid,CustName,CustCountry,CustTailor,CustEmail,regDate,Custrecomm,Custcomment)
VALUES( '',' ".$_POST['name']." ',' ".$_POST['country']." ',' ".$_POST['field']." ',' ".$_POST['email']." ',now(),' ".$_POST['recommendation']." ',' ".$_POST['commentbox']." ')";
//Output of the query and checking if we are at the right place
echo("We are here to excecute this query: ".$query);
//Query excecution with error reporting
$result=mysql_query($query) or die("Oj! We just had a problem!<br>MySQL reported: "mysql_error());
//Post-excecution message
echo('<p>Everything should be just fine! Check the database!</p>');
}


<?php
// resource dbconnect([string database name [, string user name [, string password [, string server name]]]])
// This function will connect to a MySQL database. If the attempt to connect
// fails, an error message prints out and the script will exit.
function dbconnect($dbname="XXX", $user="XXXX", $password="XXX", $server="XXXX") {
$link = mysql_connect($server, $user, $password)
or exit("<h3>could not connect to database</h3>"
. "<li>errorno => " . mysql_errno()
. "<li>error => " . mysql_error()
. "<li>Return to <a href='./'>main page</a>");
mysql_select_db($dbname)
or exit("<h3>could not select database</h3>"
. "<li>errorno => " . mysql_errno()
. "<li>error => " . mysql_error()
. "<li>Return to <a href='./'>main page</a>");
return $link;
}
// resource safe_query(string query)
// This function will execute an SQL query against the currently open
// MySQL database. If the global variable $query_debug is not empty,
// the query will be printed out before execution. If the execution fails,
// the query and any error message from MySQL will be printed out, and
// the function will return FALSE. Otherwise, it returns the MySQL
// result set identifier.
function safe_query($query) {
$result = mysql_query($query)
or exit("ack! query failed: "
."<li>errorno => ".mysql_errno()
."<li>error => ".mysql_error()
."<li>query => ".$query
."<li>Return to <a href='./'>main page</a>");
return $result;
}
?>






<?
include("db.php");
$link=dbconnect();
if(isset($_POST['mailing2'])){
$query="SELECT * from Customer WHERE CustEmail='".$_POST['email']."';";
$result=mysql_query($query) or die("Query one error: ".mysql_error());
//If no record found.The one you have used before would work in case there was an
error in mysql_num_rows() excecution. No rows is NOT an error
if(mysql_num_rows($result)==0){
$query="INSERT INTO Customer(
eid,CustName,CustCountry,CustTailor,CustEmail,regDate,Custrecomm,Custcomment)
VALUES( '',' ".$_POST['name']." ',' ".$_POST['country']." ',' ".$_POST['field']."
',' ".$_POST['email']." ',now(),' ".$_POST['recommendation']." ',' ".$_POST[
'commentbox']." ')";
//Output of the query and checking if we are at the right place
echo("We are here to excecute this query: ".$query);
//Query excecution with error reporting
$result=mysql_query($query) or die("Oj! We just had a problem!<br>MySQL reported:
".mysql_error());
//Post-excecution message
echo('<p>Everything should be just fine! Check the database!</p>');
mysql_query($query);
$message="We have received your review. Thank you very much. We hope
to give you better services through this. Please click <a href=http://www.hst.com.sg
title="Welcome to Hwa Seng Textiles Online Fabric stores"> here</a> to go back to
home page.";
}else{
$message="Sorry, We are unable to receive your Review. Please click <a href
="http://www.hst.com.sg/acatalog/Business.html" title="You are now in Hwa Seng
Online Fabric stores -Please try again. Thank you"> here</a> to enter another email
address. If it still doesn't work, please contact us at, (65)63455154 or <a href="
mailto:hstextile@hst.com.sg" title="Online Fabric stores">Email us</a>.";
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?=$message?>
</body>
</html>

$result=mysql_query($query) or die("MySQL reported:".mysql_error());


These are the following information you have sent: INSERT INTO Customer(CustName,CustCountry,CustTailor,CustEmail,regDate,Custrecomm,Custcomment) VALUES(' name ',' Ecuador ',' five ',' email ',now(),' fabric recommendation ',' comments ');
<?php
include("db.php");
$link=dbconnect();
if(isset($_POST['mailing2'])){
$query="SELECT * from Customer WHERE CustEmail='".$_POST['email']."';";
$result=mysql_query($query) or die("Query one error: ".mysql_error());
//If no record found.The one you have used before would work in case there was an error in mysql_num_rows() excecution. No rows is NOT an error
if(mysql_num_rows($result)==0){
$query="INSERT INTO Customer(CustName,CustCountry,CustTailor,CustEmail,regDate,Custrecomm,Custcomment)
VALUES(' ".$_POST['name']." ',' ".$_POST['country']." ',' ".$_POST['field']." ',' ".$_POST['email']." ',now(),' ".$_POST['recommendation']." ',' ".$_POST['commentbox']." ');";
//Output of the query and checking if we are at the right place
echo("These are the following information you have sent: ".$query);
//Query excecution with error reporting
$result=mysql_query($query) or die("Oj! We just had a problem!<br>MySQL reported: ".mysql_error());
mysql_query($query);
[b]$message="We have received your review. Thank you very much. We hope to give you better services through this. Please click <a href=http://www.hst.com.sg title='Welcome to Hwa Seng Textiles Online Fabric stores'> here</a> to go back to home page.";[/b] }else{
$message="Sorry, We are unable to receive your Review. Please click <a href='http://www.hst.com.sg/acatalog/Business.html' title='You are now in Hwa Seng Online Fabric stores -Please try again. Thank you'> here</a> to enter another email address. If it still doesn't work, please contact us at, (65)63455154 or <a href='mailto:hstextile@hst.com.sg' title='Online Fabric stores'>Email us</a>.";
}
}
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php $message ?>
</body>
</html>

Users browsing this forum: No registered users and 1 guest