PHP form insert into MySQL

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
olivierp
-


Joined: 23 Apr 2004
Posts: 54
Location: Montreal, Qc

PostPosted: Mon May 02, 2005 8:08 pm    Post subject: PHP form insert into MySQL Reply with quote

Hi all, Thanks in adcance for your help !

PHP 5 [prepackaged by Aprelium]
MySQL 4.1.11 [with Administrator]
Abyss WebServer X1

I'm trying to use a form to insert a new row in MySQL DB.
When testing the script, I do not get any errors and the proper echo is displayed but no rows were added to the table.

I tested the PHP installation with a simple php script which works fine :
Quote:
<?php
echo "Hello Dave!";
?>


I created a DB with cmd called mailing and a table called girls
The table has 2 columns in this order :
Quote:
name [also a primary key, not-null, no auto inc, and no default value]
email [not-null, no auto inc, and no default value]


Here is the php script :
Quote:
<?

mysql_connect("localhost","root","xxxxxxxx");

mysql_select_db("mailing");

$name = $_POST['name'];
$email = $_POST['email'];

$result = mysql_query("INSERT INTO girls (name,email) VALUES ('".$name."', '".$email."')");

if($result == 1){
echo "Query Finished";
}


?>


Here is the form :
Quote:
<form method="post" action="mailing.php">
<TABLE>
<TR>
<TD>Name:</TD>
<TD><INPUT TYPE='TEXT' NAME='name' size=60></TD>
</TR>
<TR>
<TD>Email:</TD>
<TD><INPUT TYPE='TEXT' NAME='email' size=60></TD>
</TR><br>
<TR>
<TD></TD><br>
<TD><INPUT TYPE="submit" name="submit" value="submit"></TD>
</TR>
</TABLE>
</form>
Back to top View user's profile Send private message
olivierp
-


Joined: 23 Apr 2004
Posts: 54
Location: Montreal, Qc

PostPosted: Mon May 02, 2005 11:36 pm    Post subject: Reply with quote

I added the proper port # beside localhost
Works fine.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group