Unable to connect php and html file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Jamil37037
New php-forum User
New php-forum User
Posts: 2
Joined: Wed Apr 17, 2013 4:24 am

Unable to connect php and html file

Postby Jamil37037 » Wed Apr 17, 2013 4:32 am

Okay i have created html registration file and connect.php file to store data into database. but connect page is unable to get data from registration page. plz help.... i am using WAMP sql server

Registration file

Code: Select all

<body>

<div id="registration">
 <h2><b><i>Electronic Montessori Learning</i><b></h2>

 <form id="RegisterUserForm" action="" method="post">
    <fieldset>
         <p>
            <label for="name">Name</label>
            <input id="name" name="name" type="text" class="text" value="" />
         </p>
        <p>
            <label for="password">Password</label>
            <input id="password" name="password" class="text" type="password" />
         </p>
       <p>
            <button id="registerNew" type="submit">Register</button>
         </p>
    </fieldset>

 </form>
</div>
<body>

I have not posted all code of registration.html as it is working fine


connect.php

Code: Select all

<?php


$db=mysql_connect("localhost", "root", "") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("users") or die(mysql_error());
echo "Connected to Database";

if(isset($_POST['registerNew']))
{
// Storing form values into PHP variables
$name = $_POST['name']; // Since method=”post” in the form
$password = $_POST['password'];
$confirmgender = $_POST["confirmpassword"];
$email = $_POST["email"];


/
mysql_query("INSERT INTO user_eml
(Name, Password) VALUES('$name', '$password' ) ")
or die(mysql_error()); 
echo "Data Inserted!";

echo   'Thank you for submitting your details!';
}
?>

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Unable to connect php and html file

Postby johnj » Wed Apr 17, 2013 5:24 am

The action in registration page is not connect.php, how are you going to connect.php?

Jamil37037
New php-forum User
New php-forum User
Posts: 2
Joined: Wed Apr 17, 2013 4:24 am

Re: Unable to connect php and html file

Postby Jamil37037 » Thu Apr 18, 2013 1:58 am

ok ichanged it but its still nopt working and when i click on register button it shows connect.php code.
Also when i replace variable with value then its storing in database
like $name="Jamil"; this is working

php code

Code: Select all


<?php


$db=mysql_connect("localhost", "root", "") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("users") or die(mysql_error());
echo "Connected to Database";


if(isset($_POST['registerNew'])){
// Storing form values into PHP variables
$name = $_POST['name']; // Since method=”post” in the form
$password = $_POST['password'];
mysql_query("INSERT INTO user_eml(Name, Password) VALUES('$name', '$password' ) ")
or die(mysql_error()); 
echo "Data Inserted!";

echo   'Thank you for submitting your details!';
}




?>

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Unable to connect php and html file

Postby johnj » Thu Apr 18, 2013 5:05 am

Please make connect.php as a HTML page, like connect.html and make that work from your registration page.
Then, make connect.php as a simple php page, maybe with just an echo statement and make that work from registration page. Then, make your current stuff work with registration page.

johnmacd
New php-forum User
New php-forum User
Posts: 19
Joined: Wed Jun 12, 2013 9:30 pm
Contact:

Re: Unable to connect php and html file

Postby johnmacd » Fri Jun 14, 2013 12:50 am

Write form name where action="___" in form tag.
<form id="RegisterUserForm" action="form name.ext" method="post">


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests