Ask a Question related to PHP Development, Design and Development.
-
Mark Johnson #1
Posting HTML Form data to MySQL via PHP
I just need a correct PHP statement that will allow me to instert a record
into a MySQL database/table. The "mysql_query(" statment used below does
not work.
----------------------------------------------------------------------------
$hostname="mysql5.secureserver.net";
$username="xxxxxxx";
$password="yyyyyy";
$dbname="zzzzzzzz";
$usertable="Visitors";
$verbindung = @mysql_connect($hostname, $username, $password)or die
("Failed");
mysql_select_db($dbname);
$firstname=$_POST['firstName'];
$lastname=$_POST['lastName'];
$address1=$_POST['address1'];
$address2=$_POST['address2'];
$city=$_POST['city'];
$state=$_POST['state'];
$zipcode=$_POST['zipCode'];
$country=$_POST['Country'];
$phone=$_POST['phone'];
$email=$_POST['eMail'];
mysql_query("INSERT INTO $usertable VALUES
'$firstname','$lastname','$address1','$address2',' $city','$state','$z
ipcode','$country','$phone','$email'");
mysql_close($verbindung);
echo "<br>Done...";
?>
----------------------------------------------------------------------------
-
--Mark
"Mark Johnson" <mdjohns5@comcast.net> wrote in message
news:4oKdnax6JMVsh-HcRVn-rA@comcast.com...corresponding> I have a very straight forward FORM in a HTML page with 10 fields (name,
> address, phone, email, etc.)
>
> On the backend I have a MySQL database/table defined with theFORM> fields.
> (FirstName, LastName,Address1,Address2,City,State,ZipCode,Coun try, Phone,
> Email)
>
> I need to know what PHP syntax to use to store the data caputred in theto> to to the MySQL database. (This is not rocket science, I am just a newbie--> MySQL/PHP.)
>
> Here is the syntax for my HTML form:
> ---------------------------------------
> <form action="scripts/mySQLTest.php" method="post" name="reg" id="reg">
>
> Here is the syntax for the PHP script: (UID/PWD changed to protect the
> innocent ;?)
> --------------------------------------------------------------------------again> ---------
> <?php
> //Database Connection Syntax for PHP and MySQL.
> //Connect To Database
>
> $hostname="mysql5.secureserver.net";
> $username="xxxxxxx";
> $password="yyyyyy";
> $dbname="zzzzzzzz";
> $usertable="Visitors";
>
> mysql_connect($hostname,$username, $password) OR DIE ("<html><script
> language='JavaScript'<alert('Unable to connect to database! Please try--> later.'),history.go(-1)</script></html>");
>
> mysql_select_db($dbname);
> ?????????????????????????????????????????????????? ???????????????
> echo "Done";
> ?>
> --------------------------------------------------------------------------manually> -----------------
>
> I know the database is set up correctly because I have been able toFORM> add records (via the Admin panel) and then write a PHP script to read that
> data and echo it out to a HTML page.
>
> I am using Macromedia Dreamweaver to create the HTML and PHP. When theproperties:> is selecetd in Dreamweaver, I can choose to alter the followingmatter).> * Action (scripts/mySQLtest.php)
> * Method (default, GET or POST) ???
> * Enctype ("", application/x-www-form-urlencoded, or multipart/form-data)
> ???
>
> In addition to needing the PHP line to post to MySQL, I need some guidance
> on what to choose for the ablve "Method" and "Enctype" (or does it>
> Thanks in advance!
>
> Mark
>
>
Mark Johnson Guest
-
Form Data not posting...
Hi, Here is the action script from movie. When I click submit the from data loads I can see it with trace. However when it gets posted to CFpage... -
ASP.NET not posting form data
Dear all, We are a library and are trying to get an ASP.NET form page working on our site. the buttons and fields appear, but we are still having... -
getting data from mysql to display in html form
hi guys, i have a mysql database with usersnames in it. i am creating a html form with a multiple listing field. i want to get the usernames form... -
Posting data from MySQL?
If you had gone to alt.php.sql first you could have found the answer without posting. There's a standard way of doing things over there which goes... -
Help: Posting data from MySQL?
rob@exau.com wrote: I'm not sure what you want, but let's see. As you have a <tr> statement that opens up each time you enter the loop, you... -
Daedalus #2
Re: Posting HTML Form data to MySQL via PHP
> mysql_query("INSERT INTO $usertable VALUES
Missing ( ) around the values after VALUES> '$firstname','$lastname','$address1','$address2',' $city','$state','$z
> ipcode','$country','$phone','$email'");
mysql_query("INSERT INTO $usertable VALUES
('$firstname','$lastname','$address1','$address2', '$city',
'$state','$zipcode','$country','$phone','$email')" );
Dae
Daedalus Guest



Reply With Quote

