unable to connect php to mysql using xampp

Problems with the Windows version of XAMPP, questions, comments, and anything related.

unable to connect php to mysql using xampp

Postby sprouts11 » 20. March 2013 19:25

I am having trouble connecting to mysql database. The page loads fine with my 3 text boxes. When I populate the text boxes and click 'register' nothing happens. What I'm expecting to see is '1 row inserted' and for the data to be populated in mysql.

Can anybody HELP! Thanks!

Here is my code below...
------------------------------------------------------------------------------------
<html>
<head>
<title></title>
</head>
<body>
<form>
<form method="POST" action="insert.php">
Name: <input type="text" name="name" /> <br />
Email: <input type="text" name="email" /><br />
Password: <input type="password" name="password" /><br />
<p>
<input type="submit" name="submit" value="register" /><br />
</form>
</body>
</html>
---------------------------------------------------------------------------------------------
<?php

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

if($name && $email && $password){

mysql_connect("localhost", "root", "") or die("We could not connect!");

mysql_select_db("testing");

mysql_query("INSERT INTO accounts(name,email,password) VALUES('$name','$email','$password')");

$registered = mysql_affected_rows();

echo "$registered was inserted";

}else{

echo "you have to complete the form!";

}

mysql_close();
?>
sprouts11
 
Posts: 1
Joined: 20. March 2013 19:17
Operating System: windows vista home

Re: unable to connect php to mysql using xampp

Postby Altrea » 20. March 2013 19:39

sprouts11 wrote:<form>
<form method="POST" action="insert.php">


And you should learn how to debug your code.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11926
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 106 guests