For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > February 2005 > Entering data from a form into mySQL









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Entering data from a form into mySQL
ozy

2005-02-17, 4:00 pm

Help needed!

Below is the php code I have written. (I am a newbie so be kind).

What i want to do. A form passes data to this script which sends me a email,
then it saves it into a 'CSV' file. Although the code my be a bit scrappy is
works.
The last part which i wish to achive is to save the info into a mySQL
database. At first it returned an error in the 'sql' line ($sql="INSERT INTO
DVL). After changing the line I now get no errors, but nothing is recorded
in the database.
On a seperate php page i can access the database and display the results no
problem.

Any help would be great
Thank in advance

________________________________________
____________________________________
__________
<?php
function mailit()
//SEND EMAIL+++++++++++++++++++++++++++++++++++
+++++++++++++
{
$sendTo = bloggs@bloggs.com;
$subject = "Reply Form Flyer\n\n";
// ++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
$headers = "From: " . $_POST["name"];
$headers .= "<" . $_POST["email"] .">\r\n\n";
// ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
$headers .= "CONTACT INFO: " ."\n";
$headers .=
" ========================================
====================\n";
$headers .= " NAME: " . $_POST["Name"] ."\n";
$headers .= " EMAIL ADDRESS : " . $_POST["email"] ."\n";
$headers .= " POSTCODE : " . $_POST["PostCode"] ."\n";
$headers .= " PHONE NO: " . $_POST["phone"] ."\n\n\n";
$headers .= "DETAILS: " . "\n";
$headers .=
" ========================================
====================\n";
$headers .= " MAKE : " . $_POST["Make"] ."\n";
$headers .= " MODEL : " . $_POST["Model"] ."\n";
$headers .= " LENGTH OF CONTRACT : " .
$_POST["Length_Contract"] ."\n";
$headers .= " MILEAGE : " . $_POST["Mileage"] ."\n";
$headers .= " TYPE OF QUOTE : " . $_POST["Type_of_Quote"]
.."\n";
$headers .= " BUSINESS NAME : " . $_POST["Business_Name"]
.."\n";

// ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
mail($sendTo, $subject, $message, $headers);

// ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
header ("Location:http://thankyou form");
}

function checkit()
{
if (!ereg(".+@",$_POST["email"]))
{
header ("Location:http://error form");
}else{
mailit();
record();

}
}

function record()
{
// ++++++++++++++++++++++++++++++++++++++++
++
// RECORD FORM DATA IN CSV FILE
// ++++++++++++++++++++++++++++++++++++++++
+++
if (!$file_op = fopen("quotefile.csv","a")){
echo ("sorry can't open file");
}

fputs($file_op,"\n");
fputs($file_op,$_POST["Name"]);
fputs($file_op,",".$_POST["email"]);
fputs($file_op,",".$_POST["PostCode"]);
fputs($file_op,",".$_POST["phone"]);
fputs($file_op,",".$_POST["Business_Name"]);
fputs($file_op,",".$_POST["Type_of_Quote"]);
fputs($file_op,",".$_POST["Make"]);
fputs($file_op,",".$_POST["Model"]);
fputs($file_op,",".$_POST["Length_Contract"]);
fputs($file_op,",".$_POST["Mileage"]);

fclose($file_op);

// ++++++++++++++++++++++++++++++++++++++++
++
// RECORD FORM DATA IN sql database
// ++++++++++++++++++++++++++++++++++++++++
+++
$datennow=(date("j F Y"));
$connection=mysql_connect("server","user","password");

if (!connection){
echo ("Could not connect");
exit;
}else{
echo ("ok");
}

$db=mysql_select_db("database",$connection);

if (!$db){
echo("Could not change");
exit;
}

$sql="INSERT INTO DVL
(date,name,email,postcode,phone,busname,
typeofquote,make,model,length,milage
) VALUES
('$datenow',".$_POST['Name'].",".$_POST['email'].",".$_POST['PostCode'].",".
$_POST['phone'].",".$_POST['Business_Name'].",".$_POST['Type_of_Quote'].",".
$_POST['Make'].",".$_POST['Model'].",".$_POST['Length_Contract'].",".$_POST[
'Mileage'].")";

if (!mysql_query($sql,$Connection)){
echo "error";
exit;
}else{
echo "done ok";
}

}

checkit();
?>


Geoff Berrow

2005-02-17, 4:00 pm

I noticed that Message-ID: <kn1Rd.213$Wz1.111@newsfe4-gui.ntli.net> from
ozy contained the following:

>".$_POST['Name'].",


try '$_POST[Name]',


--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
ozy

2005-02-17, 4:00 pm

Tried the fix below. Sorry still not working.

thanks
ozy


"Geoff Berrow" <blthecat@ckdog.co.uk> wrote in message
news:nm8911h9he7cvjjho594tp4jbk41h47b2m@
4ax.com...
> I noticed that Message-ID: <kn1Rd.213$Wz1.111@newsfe4-gui.ntli.net> from
> ozy contained the following:
>
>
> try '$_POST[Name]',
>
>
> --
> Geoff Berrow (put thecat out to email)
> It's only Usenet, no one dies.
> My opinions, not the committee's, mine.
> Simple RFDs http://www.ckdog.co.uk/rfdmaker/



Alex Hopson

2005-02-17, 4:00 pm

try echoing out the query then you can see if there's a problem(ie wrong
data or empty fields), you can also try using phpmyadmin or similar to un
the sql and maybe then you will be able to see if there is a problem with
the query.

Alex


"ozy" <ozy@ozy.com> wrote in message
news:kn1Rd.213$Wz1.111@newsfe4-gui.ntli.net...
> Help needed!
>
> Below is the php code I have written. (I am a newbie so be kind).
>
> What i want to do. A form passes data to this script which sends me a
> email,
> then it saves it into a 'CSV' file. Although the code my be a bit scrappy
> is
> works.
> The last part which i wish to achive is to save the info into a mySQL
> database. At first it returned an error in the 'sql' line ($sql="INSERT
> INTO
> DVL). After changing the line I now get no errors, but nothing is recorded
> in the database.
> On a seperate php page i can access the database and display the results
> no
> problem.
>
> Any help would be great
> Thank in advance
>
> ________________________________________
____________________________________
> __________
> <?php
> function mailit()
> //SEND EMAIL+++++++++++++++++++++++++++++++++++
+++++++++++++
> {
> $sendTo = bloggs@bloggs.com;
> $subject = "Reply Form Flyer\n\n";
> // ++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
> $headers = "From: " . $_POST["name"];
> $headers .= "<" . $_POST["email"] .">\r\n\n";
> // ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
> $headers .= "CONTACT INFO: " ."\n";
> $headers .=
> " ========================================
====================\n";
> $headers .= " NAME: " . $_POST["Name"] ."\n";
> $headers .= " EMAIL ADDRESS : " . $_POST["email"] ."\n";
> $headers .= " POSTCODE : " . $_POST["PostCode"] ."\n";
> $headers .= " PHONE NO: " . $_POST["phone"] ."\n\n\n";
> $headers .= "DETAILS: " . "\n";
> $headers .=
> " ========================================
====================\n";
> $headers .= " MAKE : " . $_POST["Make"] ."\n";
> $headers .= " MODEL : " . $_POST["Model"] ."\n";
> $headers .= " LENGTH OF CONTRACT : " .
> $_POST["Length_Contract"] ."\n";
> $headers .= " MILEAGE : " . $_POST["Mileage"] ."\n";
> $headers .= " TYPE OF QUOTE : " . $_POST["Type_of_Quote"]
> ."\n";
> $headers .= " BUSINESS NAME : " . $_POST["Business_Name"]
> ."\n";
>
> // ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
> mail($sendTo, $subject, $message, $headers);
>
> // ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
> header ("Location:http://thankyou form");
> }
>
> function checkit()
> {
> if (!ereg(".+@",$_POST["email"]))
> {
> header ("Location:http://error form");
> }else{
> mailit();
> record();
>
> }
> }
>
> function record()
> {
> // ++++++++++++++++++++++++++++++++++++++++
++
> // RECORD FORM DATA IN CSV FILE
> // ++++++++++++++++++++++++++++++++++++++++
+++
> if (!$file_op = fopen("quotefile.csv","a")){
> echo ("sorry can't open file");
> }
>
> fputs($file_op,"\n");
> fputs($file_op,$_POST["Name"]);
> fputs($file_op,",".$_POST["email"]);
> fputs($file_op,",".$_POST["PostCode"]);
> fputs($file_op,",".$_POST["phone"]);
> fputs($file_op,",".$_POST["Business_Name"]);
> fputs($file_op,",".$_POST["Type_of_Quote"]);
> fputs($file_op,",".$_POST["Make"]);
> fputs($file_op,",".$_POST["Model"]);
> fputs($file_op,",".$_POST["Length_Contract"]);
> fputs($file_op,",".$_POST["Mileage"]);
>
> fclose($file_op);
>
> // ++++++++++++++++++++++++++++++++++++++++
++
> // RECORD FORM DATA IN sql database
> // ++++++++++++++++++++++++++++++++++++++++
+++
> $datennow=(date("j F Y"));
> $connection=mysql_connect("server","user","password");
>
> if (!connection){
> echo ("Could not connect");
> exit;
> }else{
> echo ("ok");
> }
>
> $db=mysql_select_db("database",$connection);
>
> if (!$db){
> echo("Could not change");
> exit;
> }
>
> $sql="INSERT INTO DVL
> (date,name,email,postcode,phone,busname,
typeofquote,make,model,length,milage
> ) VALUES
> ('$datenow',".$_POST['Name'].",".$_POST['email'].",".$_POST['PostCode'].",".
> $_POST['phone'].",".$_POST['Business_Name'].",".$_POST['Type_of_Quote'].",".
> $_POST['Make'].",".$_POST['Model'].",".$_POST['Length_Contract'].",".$_POST[
> 'Mileage'].")";
>
> if (!mysql_query($sql,$Connection)){
> echo "error";
> exit;
> }else{
> echo "done ok";
> }
>
> }
>
> checkit();
> ?>
>
>




Fat Bloke

2005-02-17, 4:00 pm

On Thu, 17 Feb 2005 13:55:28 GMT, "ozy" <ozy@ozy.com> wrote:

>Help needed!
>
>Below is the php code I have written. (I am a newbie so be kind).
>
>What i want to do. A form passes data to this script which sends me a email,
>then it saves it into a 'CSV' file. Although the code my be a bit scrappy is
>works.
>The last part which i wish to achive is to save the info into a mySQL
>database. At first it returned an error in the 'sql' line ($sql="INSERT INTO
>DVL). After changing the line I now get no errors, but nothing is recorded
>in the database.
>On a seperate php page i can access the database and display the results no
>problem.
>
>Any help would be great
>Thank in advance
>
> ________________________________________
____________________________________
>__________
><?php
>function mailit()
>//SEND EMAIL+++++++++++++++++++++++++++++++++++
+++++++++++++
>{
> $sendTo = bloggs@bloggs.com;
> $subject = "Reply Form Flyer\n\n";
> // ++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
> $headers = "From: " . $_POST["name"];
> $headers .= "<" . $_POST["email"] .">\r\n\n";
> // ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
> $headers .= "CONTACT INFO: " ."\n";
> $headers .=
>" ========================================
====================\n";
> $headers .= " NAME: " . $_POST["Name"] ."\n";
> $headers .= " EMAIL ADDRESS : " . $_POST["email"] ."\n";
> $headers .= " POSTCODE : " . $_POST["PostCode"] ."\n";
> $headers .= " PHONE NO: " . $_POST["phone"] ."\n\n\n";
> $headers .= "DETAILS: " . "\n";
> $headers .=
>" ========================================
====================\n";
> $headers .= " MAKE : " . $_POST["Make"] ."\n";
> $headers .= " MODEL : " . $_POST["Model"] ."\n";
> $headers .= " LENGTH OF CONTRACT : " .
>$_POST["Length_Contract"] ."\n";
> $headers .= " MILEAGE : " . $_POST["Mileage"] ."\n";
> $headers .= " TYPE OF QUOTE : " . $_POST["Type_of_Quote"]
>."\n";
> $headers .= " BUSINESS NAME : " . $_POST["Business_Name"]
>."\n";
>
>// ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
> mail($sendTo, $subject, $message, $headers);
>
>// ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
> header ("Location:http://thankyou form");
>}
>
>function checkit()
>{
> if (!ereg(".+@",$_POST["email"]))
> {
> header ("Location:http://error form");
> }else{
> mailit();
> record();
>
> }
>}
>
>function record()
>{
>// ++++++++++++++++++++++++++++++++++++++++
++
>// RECORD FORM DATA IN CSV FILE
>// ++++++++++++++++++++++++++++++++++++++++
+++
>if (!$file_op = fopen("quotefile.csv","a")){
> echo ("sorry can't open file");
> }
>
> fputs($file_op,"\n");
> fputs($file_op,$_POST["Name"]);
> fputs($file_op,",".$_POST["email"]);
> fputs($file_op,",".$_POST["PostCode"]);
> fputs($file_op,",".$_POST["phone"]);
> fputs($file_op,",".$_POST["Business_Name"]);
> fputs($file_op,",".$_POST["Type_of_Quote"]);
> fputs($file_op,",".$_POST["Make"]);
> fputs($file_op,",".$_POST["Model"]);
> fputs($file_op,",".$_POST["Length_Contract"]);
> fputs($file_op,",".$_POST["Mileage"]);
>
> fclose($file_op);
>
>// ++++++++++++++++++++++++++++++++++++++++
++
>// RECORD FORM DATA IN sql database
>// ++++++++++++++++++++++++++++++++++++++++
+++
>$datennow=(date("j F Y"));
>$connection=mysql_connect("server","user","password");
>
>if (!connection){
> echo ("Could not connect");
> exit;
> }else{
> echo ("ok");
> }
>
>$db=mysql_select_db("database",$connection);
>
>if (!$db){
> echo("Could not change");
> exit;
> }
>
>$sql="INSERT INTO DVL
> (date,name,email,postcode,phone,busname,
typeofquote,make,model,length,milage
> ) VALUES
>('$datenow',".$_POST['Name'].",".$_POST['email'].",".$_POST['PostCode'].",".
>$_POST['phone'].",".$_POST['Business_Name'].",".$_POST['Type_of_Quote'].",".
>$_POST['Make'].",".$_POST['Model'].",".$_POST['Length_Contract'].",".$_POST[
>'Mileage'].")";
>
>if (!mysql_query($sql,$Connection)){
>echo "error";
> exit;
> }else{
> echo "done ok";
> }
>
>}
>
>checkit();
>?>
>

Unless you have an especial use for the file to be written, why not dump the
stuff straight into the database?
I'm fairly new to php, too, and some of the experts around here may think
the following a bit naive, but it's straight out of a working site of mine.
Add your chosen security and value-checks.

"guest_book.php"
<?
include("php-lib/header_public.php");
?>
<table width=780 cellspacing=0 cellpadding=0 border=0>
<tr><td><br>
<table width=770 align=center cellspacing=0 cellpadding=0 border=4
rules=none bgcolor="#ffffee">
<tr><td><br>
<blockquote><strong>Please make an entry in our Guest Book - let us know
what you think of the XYZ .</strong></blockquote></td></tr>
<form method=post action="guest_book_add_handle.php">
<tr><td>
<table width=590 align=center cellspacing=0 cellpadding=2 border=0>
<tr><td>First name<br><input type=text name="firstname"
size=16></td><td>Surname<br><input type=text name="surname"
size=42></td></tr>
<tr><td colspan=2>Your e-mail address <br><input type=text name="email"
size=72></td></tr><tr><td colspan=2>Your comments - about our website? -
about XYZ? <br><textarea name="comments" cols=68
rows=12></textarea></td></tr>
<tr><td align=center></td><td align=right><input type=submit name="submit"
value="Enter"></td></tr>
</table>
</form>
</td></tr></table>
<?
include("php-lib/footer_public.php");
?>

"guest_book_add_handle.php"
<?
if ((!$firstname) || (!$surname) || (!$email) || (!$comments))
{
header("location:guest_book.php");
exit();
}
include("php-lib/header_public.php");

$date=date("jS F Y", strtotime($Row[date]));
mail("admin@mydomain", "Guest book", "New contribution to the XYZ Guest Book
- $date.");
include("connect_inc.php");

$firstname=trim($firstname);
$surname=trim($surname);
$comments=trim($comments);
$comments=nl2br($comments);
$email=trim ($email);
$email=strtolower($email);
$TableName="guest_book";
$Query="INSERT INTO $TableName (id, vis, firstname, surname, email,
comments, date_added) VALUES ('', \"P\", '$firstname', '$surname', '$email',
'$comments', curdate() )";
$Result=mysql_db_Query ($DBName, $Query, $Link);

mysql_close ($Link);
?>
<table width=770 cellspacing=0 cellpadding=0 border=0>
<tr><td><br> <br>
<table width=690 align=center cellspacing=0 cellpadding=8 border=0>
<tr><td align=center>Thank you!   Your entry will shortly appear in our
Guest Book.<br> <br> </td></tr></table>
<?
include("php-lib/footer_public.php");
?>

HTH.
------------------------------------------------------------

This post did not necessarily reflect my opinions. So there.
Pull the pins out to reply direct.
Fat Bloke

2005-02-21, 3:56 am

On Thu, 17 Feb 2005 13:55:28 GMT, "ozy" <ozy@ozy.com> wrote:

>Help needed!
>
>Below is the php code I have written. (I am a newbie so be kind).
>
>What i want to do. A form passes data to this script which sends me a email,
>then it saves it into a 'CSV' file. Although the code my be a bit scrappy is
>works.
>The last part which i wish to achive is to save the info into a mySQL
>database. At first it returned an error in the 'sql' line ($sql="INSERT INTO
>DVL). After changing the line I now get no errors, but nothing is recorded
>in the database.
>On a seperate php page i can access the database and display the results no
>problem.
>
>Any help would be great
>Thank in advance
>
> ________________________________________
____________________________________
>__________
><?php
>function mailit()
>//SEND EMAIL+++++++++++++++++++++++++++++++++++
+++++++++++++
>{
> $sendTo = bloggs@bloggs.com;
> $subject = "Reply Form Flyer\n\n";
> // ++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++
> $headers = "From: " . $_POST["name"];
> $headers .= "<" . $_POST["email"] .">\r\n\n";
> // ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++
> $headers .= "CONTACT INFO: " ."\n";
> $headers .=
>" ========================================
====================\n";
> $headers .= " NAME: " . $_POST["Name"] ."\n";
> $headers .= " EMAIL ADDRESS : " . $_POST["email"] ."\n";
> $headers .= " POSTCODE : " . $_POST["PostCode"] ."\n";
> $headers .= " PHONE NO: " . $_POST["phone"] ."\n\n\n";
> $headers .= "DETAILS: " . "\n";
> $headers .=
>" ========================================
====================\n";
> $headers .= " MAKE : " . $_POST["Make"] ."\n";
> $headers .= " MODEL : " . $_POST["Model"] ."\n";
> $headers .= " LENGTH OF CONTRACT : " .
>$_POST["Length_Contract"] ."\n";
> $headers .= " MILEAGE : " . $_POST["Mileage"] ."\n";
> $headers .= " TYPE OF QUOTE : " . $_POST["Type_of_Quote"]
>."\n";
> $headers .= " BUSINESS NAME : " . $_POST["Business_Name"]
>."\n";
>
>// ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
> mail($sendTo, $subject, $message, $headers);
>
>// ++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++
> header ("Location:http://thankyou form");
>}
>
>function checkit()
>{
> if (!ereg(".+@",$_POST["email"]))
> {
> header ("Location:http://error form");
> }else{
> mailit();
> record();
>
> }
>}
>
>function record()
>{
>// ++++++++++++++++++++++++++++++++++++++++
++
>// RECORD FORM DATA IN CSV FILE
>// ++++++++++++++++++++++++++++++++++++++++
+++
>if (!$file_op = fopen("quotefile.csv","a")){
> echo ("sorry can't open file");
> }
>
> fputs($file_op,"\n");
> fputs($file_op,$_POST["Name"]);
> fputs($file_op,",".$_POST["email"]);
> fputs($file_op,",".$_POST["PostCode"]);
> fputs($file_op,",".$_POST["phone"]);
> fputs($file_op,",".$_POST["Business_Name"]);
> fputs($file_op,",".$_POST["Type_of_Quote"]);
> fputs($file_op,",".$_POST["Make"]);
> fputs($file_op,",".$_POST["Model"]);
> fputs($file_op,",".$_POST["Length_Contract"]);
> fputs($file_op,",".$_POST["Mileage"]);
>
> fclose($file_op);
>
>// ++++++++++++++++++++++++++++++++++++++++
++
>// RECORD FORM DATA IN sql database
>// ++++++++++++++++++++++++++++++++++++++++
+++
>$datennow=(date("j F Y"));
>$connection=mysql_connect("server","user","password");
>
>if (!connection){
> echo ("Could not connect");
> exit;
> }else{
> echo ("ok");
> }
>
>$db=mysql_select_db("database",$connection);
>
>if (!$db){
> echo("Could not change");
> exit;
> }
>
>$sql="INSERT INTO DVL
> (date,name,email,postcode,phone,busname,
typeofquote,make,model,length,milage
> ) VALUES
>('$datenow',".$_POST['Name'].",".$_POST['email'].",".$_POST['PostCode'].",".
>$_POST['phone'].",".$_POST['Business_Name'].",".$_POST['Type_of_Quote'].",".
>$_POST['Make'].",".$_POST['Model'].",".$_POST['Length_Contract'].",".$_POST[
>'Mileage'].")";
>
>if (!mysql_query($sql,$Connection)){
>echo "error";
> exit;
> }else{
> echo "done ok";
> }
>
>}
>
>checkit();
>?>
>

Unless you have an especial use for the file to be written, why not dump the
stuff straight into the database?
I'm fairly new to php, too, and some of the experts around here may think
the following a bit naive, but it's straight out of a working site of mine.
Add your chosen security and value-checks.

"guest_book.php"
<?
include("php-lib/header_public.php");
?>
<table width=780 cellspacing=0 cellpadding=0 border=0>
<tr><td><br>
<table width=770 align=center cellspacing=0 cellpadding=0 border=4
rules=none bgcolor="#ffffee">
<tr><td><br>
<blockquote><strong>Please make an entry in our Guest Book - let us know
what you think of the XYZ .</strong></blockquote></td></tr>
<form method=post action="guest_book_add_handle.php">
<tr><td>
<table width=590 align=center cellspacing=0 cellpadding=2 border=0>
<tr><td>First name<br><input type=text name="firstname"
size=16></td><td>Surname<br><input type=text name="surname"
size=42></td></tr>
<tr><td colspan=2>Your e-mail address <br><input type=text name="email"
size=72></td></tr><tr><td colspan=2>Your comments - about our website? -
about XYZ? <br><textarea name="comments" cols=68
rows=12></textarea></td></tr>
<tr><td align=center></td><td align=right><input type=submit name="submit"
value="Enter"></td></tr>
</table>
</form>
</td></tr></table>
<?
include("php-lib/footer_public.php");
?>

"guest_book_add_handle.php"
<?
if ((!$firstname) || (!$surname) || (!$email) || (!$comments))
{
header("location:guest_book.php");
exit();
}
include("php-lib/header_public.php");

$date=date("jS F Y", strtotime($Row[date]));
mail("admin@mydomain", "Guest book", "New contribution to the XYZ Guest Book
- $date.");
include("connect_inc.php");

$firstname=trim($firstname);
$surname=trim($surname);
$comments=trim($comments);
$comments=nl2br($comments);
$email=trim ($email);
$email=strtolower($email);
$TableName="guest_book";
$Query="INSERT INTO $TableName (id, vis, firstname, surname, email,
comments, date_added) VALUES ('', \"P\", '$firstname', '$surname', '$email',
'$comments', curdate() )";
$Result=mysql_db_Query ($DBName, $Query, $Link);

mysql_close ($Link);
?>
<table width=770 cellspacing=0 cellpadding=0 border=0>
<tr><td><br> <br>
<table width=690 align=center cellspacing=0 cellpadding=8 border=0>
<tr><td align=center>Thank you!   Your entry will shortly appear in our
Guest Book.<br> <br> </td></tr></table>
<?
include("php-lib/footer_public.php");
?>

HTH.
------------------------------------------------------------

This post did not necessarily reflect my opinions. So there.
Pull the pins out to reply direct.
Geoff Berrow

2005-02-21, 8:56 am

I noticed that Message-ID: <kn1Rd.213$Wz1.111@newsfe4-gui.ntli.net> from
ozy contained the following:

>".$_POST['Name'].",


try '$_POST[Name]',


--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com