Getting PHP registration form to connect with MYSQL

0 votes

I'm building a test site and my test form is working fine. But when I submit my form it says "cannot find page". What am I doing wrong?

Code:

<?php

if(isset($_POST['username']) && isset($_POST['password']))
{
$db =connect('jsnow_jsnow','missysnow2005');
if($db!=false)
{
   register($db);
   echo "User registered";
} 

}

function connect($dbuser,$dbpassword)
{
    try{
        $db = new  PDO('mysql:host=localhost;dbname=jsnow_login',$dbuser,$dbpassword);
        return $db;
    }catch(PDOException $e){
        echo $e;
        return false;}
}

function register($db)
{
    $user = mysql_real_escape_string($_POST['username']);
    $password = sha1($_POST['password']);
    $email = mysql_real_escape_string($_POST['e_mail']);

    $query = "INSERT INTO members(username,password,email) values('".$user."','".$password."','".$email."')";
    try{
        $db->eginTransaction();
        $db->exec($query);
        $db->commit();
        echo "commit succesful";
    }catch(Exception $e){}
}

?>


<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="http://localhost/jsnow_login/registration.php" method="post">
username:<input type="text" name="username"/>
password:<input type="password" name="password"/>
email<input type="text" name="e_mail"/>
<input type="submit"/>

</form>


</body>
</html>

Can someone help me with this?

May 30 in PHP by Kichu
• 19,040 points
11 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In PHP

0 votes
1 answer

How to Validate Form Data With PHP?

Hey @kartik, The first thing we will do ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,700 points
1,249 views
0 votes
1 answer

What is Php Mysql Database? How php connect to database?

Hello kartik, MySQL is the most popular database ...READ MORE

answered Feb 25, 2020 in PHP by Dey
453 views
0 votes
1 answer

How to convert from MySQL datetime to another format with PHP?

Hello, To convert a date retrieved from MySQL ...READ MORE

answered May 19, 2020 in PHP by Niroj
• 82,700 points
823 views
0 votes
0 answers
0 votes
1 answer

What are the vulnerability related to PHP Form?

Hii, The $_SERVER["PHP_SELF"] variable can be used by ...READ MORE

answered Feb 13, 2020 in PHP by Niroj
• 82,700 points
1,138 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
4,476 views
0 votes
1 answer

Vertically centering text in a div

Try this code: .smallUnitBox { ...READ MORE

answered Sep 3, 2018 in Blockchain by digger
• 26,720 points
247 views
0 votes
1 answer
0 votes
0 answers

Anyone can help me out to understand the semantic of (document.getElementBYId("demo").innerHTML="Hello") ?

Hello guys, Can Someone helps me to find ...READ MORE

Jan 17, 2020 in Web Development by anonymous
• 37,500 points
380 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP