2
Contributors
6
Replies
24
Views
3 Years
Discussion Span
Last Post by Ryan Huxley
0

Yes I have, I've already made a database within myPHP in my hosting website. And now I'm having trouble connecting to the database from my website.

This is my registration.php

<?php

$user_name = "xxx";
$password = "";
$database = "website";
$server = "xxx";

mysql_connect($server, $user_name, $password);

mysql_select_db($database, $db_handle);

("INSERT INTO `website` ( `fname`, `lname`, `email`, `username`,`password`) 
VALUES 
('$_POST[first_name]','$_POST[last_name],'$_POST[email]','$_POST[username]','$_POST[password]')"); 
echo "success";
?>

And this is the signup.html:

<html><head><title>Sign Up</title></head>
<body bgcolor="yellow">
<p>Registration Form </p>
<table><td>
<form method="post" action="registration.php">
<p>Username:</p>
<input type="text" name="username">
<p>Password:</p>
<input type="password" name="pw">
<p>First name:</p>
<input type="text" name="fname">
<p>Last name:</p>
<input type= "text" name="lname">
<p>Email:</p>
<input type="text" name="email">
<input type="submit">
</form></td>
</table>
</body>
</html> 

It just doesn't seem to work.

Edited by pritaeas: Removed credentials.

0

No not really, I kinda put the codes in the wrong way in Dreamweaver but I solved that.

Now weird thing is I'm getting problems trying to connect to the mysql server.
It keeps saying this in error: "Host 'xx.xx.xx.xx' is not allowed to connect to this MySQL server in /xx/xxx/xxx/registration.php on line 2"

My current registration.php:
(Note: yes my username and database name is the same, I kinda accidentally named it the same)
(Note2: my webhost told me to use mysql2.000webhost.com as the host name)

<?php
mysql_connect('xxx.000webhost.com','xxx','xxx') or die("Cannot connect.");
mysql_select_db('xxx') or die("Cannot connect.");
mysql_query
("INSERT INTO `website` ( `fname`, `lname', `email`, `username`,`password`) 
VALUES 
('$_POST[first_name]','$_POST[last_name]'$_POST[email]','$_POST[username]','$_POST[pw]')"); 
echo "Registration success!";
?> 

Edited by pritaeas: Removed credentials.

0

Oh I kinda fixed it again, I made a new database with different username & database name and it works now.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.