Hi,
Ive created a form in html and written code in hp tht takes data feom html and stores it in MySQL database. Bt wen i click on the submit button i get an error. Instead of storing it in database it asks to open the php file which has bees specified in the action attribute of the form tag. It is being created for windows platform.
Im pasting the code of both the html and php file that ive used and plz let me know how to fix that problem.
File name:form.html -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
<HTML xmlns="http://www.w3.org/1999/xhtml">
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
<HEAD>
-
<TITLE>Form Handling with PHP</TITLE>
-
</HEAD>
-
<BODY BGCOLOR="#FFFFFF">
-
<FORM METHOD=POST ACTION="add.php">
-
<input type="hidden" name="id" value="NULL">
-
<TABLE>
-
<TR height="20">
-
<TD colspan="2"><FONT SIZE="+0" face="verdana"> Below is a Sample Form for our PHP tutorial</TD>
-
</TR>
-
<TR height="50">
-
<td></td>
-
</TR>
-
<TR>
-
<TD align="left"><FONT SIZE="+0" face="verdana"> <b>Your Name <br>
-
Your E-Mail Address</b></td>
-
<td><INPUT TYPE="text" NAME="name">
-
<br>
-
<INPUT TYPE="text" NAME="email">
-
</TD>
-
</TR>
-
<tr>
-
<td colspan="2"><center>
-
<SELECT NAME="opinion">
-
<option value="is great">I like your site</option>
-
<option value="is OK">Your Site is OK</option>
-
<option value="is horrible">Your Site is horrible</option>
-
</SELECT>
-
<INPUT TYPE="submit" value="Tell us!">
-
</td>
-
</tr>
-
</TABLE>
-
</FORM>
-
</BODY>
-
</HTML>
-
Filename:add.php -
<?
-
$DBhost = "localhost";
-
$DBuser = "root";
-
$DBpass = "database";
-
$DBName = "test";
-
$table = "information";
-
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
-
-
@mysql_select_db("$DBName") or die("Unable to select
-
database $DBName");
-
-
$sqlquery = "INSERT INTO $table
-
VALUES('$id','$name','$email','$opinion')";
-
-
$results = mysql_query($sqlquery);
-
-
mysql_close();
-
-
print "<HTML><TITLE> PHP and MySQL </TITLE><BODY
-
BGCOLOR=\"#FFFFFF\"><center><table border=\"0\"
-
width=\"500\"><tr><td>";
-
print "<p><font face=\"verdana\" size=\"+0\"> <center>You
-
Just Entered This Information Into the
-
Database<p><blockquote>";
-
print "Name : $name<p>E-Mail : $email<p>Opinion :
-
$opinion</blockquote></td></tr></table>
-
</center></BODY></HTML>";
-
?>
-
Plz help me out as soon as possible.
Thanks
18 1884
Are you executing these pages with a web server, then what is it?
Is php is configured to work with the web server?
This is Not a Good thread title;
Error in connecting php mysql and html (Plz help urgently)
But this is
Error in connecting php mysql and html
So avoid using these words *please* *help* *urgent*
and make sure to use the CODE tags. refer to Posting guidelines first
Thanks
Are you executing these pages with a web server, then what is it?
Is php is configured to work with the web server?
Im using xampp to run this web pages.php is configured in it. Ive created the database in MySQL using xampp. Plz let me know
Thanks
Im using xampp to run this web pages.php is configured in it. Ive created the database in MySQL using xampp. Plz let me know
Thanks
Is xampp running (check apache)?
Ar you saving the files in the righte directory (htdocs)?
Hey thanks my that problem has got solved. I saved in wrong folder. Can u plz tel me like when user fills form i had asked him to retype pssword to confirm. What is the way that we verify it. Plz let me know how to do this. Is there a function available or v hve to apply some logic
Hey thanks my that problem has got solved. I saved in wrong folder. Can u plz tel me like when user fills form i had asked him to retype pssword to confirm. What is the way that we verify it. Plz let me know how to do this. Is there a function available or v hve to apply some logic
Well, you can either use javascript or php?
Javascript is client side, and therefore we can alert the user before the form is submitted.
ORRRRRRRRRRRRRRR!
Php, server side, this could be used in add.php and then notify the user that the passwords didnt match and provide a back button for him to return and try again!
Here's an example for javascript : -
function validatePassword()
-
{
-
var passWord = document.form_name.input_name.value;
-
var passWordS = document.form_name.input_name.value;
-
if(passWord == passWordS)
-
{
-
// the passwords matched ... submit form
-
document.form_name.submit();
-
}
-
else
-
{
-
// the passwords DIDNT match ... alert user
-
alert("Sorry, there was an error:\n\nPasswords didn't match");
-
document.form_name.input_name.focus();
-
return false;
-
}
-
}
-
Obviously, you'd have to adapt it to your form and use the correct form_name's and input_name's
And a php method:
[php]
$_passwordA = $_POST['passwordA'];
$_passwordB = $_POST['passwordB'];
if($_passwordA == $_passwordB)
{
// passwords matched
// execute the code.
}
else
{
// passes didnt match:
echo "The passwords you provided didn't match<br />";
echo "Please use <a href=\"javascript : history.back();\">this link</a> to return to the form!";
}
[/php]
Hope this helps you :)
hi,
I tried using your php code but it didnt worked out. Ive attached my php file below without the pasword code.
Plz try n tel me if it works.
html filename is register.html and php filename is process.php
Plz let me know.
PHP file -
<?php
-
-
# THIS CODE DEFINES THE DATABASE TO BE FILLED
-
$hostname = "localhost";
-
$db_user = "root";
-
$db_password = "database";
-
$db_name = "skills_portfolio";
-
$db_table1 = "functionalarea";
-
$db_table2 = "functionalrole";
-
$db_table3 = "institute";
-
$db_table4 = "qualification";
-
$db_table5 = "specialization";
-
$db_table6 = "tagmaster";
-
$db_table7 = "userdetails";
-
$db_table8 = "usermaster";
-
$db_table9 = "usertags";
-
-
# THIS CODE IS USED TO CONNECT TO THE MYSQL DATABASE
-
$dbi=mysql_connect($hostname, $db_user, $db_password);
-
mysql_select_db($db_name,$dbi);
-
-
if (isset($_REQUEST['Submit']))
-
{
-
# THIS CODE INSERTS THE DATA FROM THE FORM INTO MYSQL TABLE
-
-
mysql_query( "INSERT INTO $db_table1(AreaName)values('$_POST[AreaName]')")
-
or die(mysql_error());
-
-
mysql_query("INSERT INTO $db_table2(RoleName) values('$_POST[RoleName]')")
-
or die(mysql_error());
-
-
mysql_query("INSERT INTO $db_table3(InstituteName)
-
values('$_POST[InstituteName]')")
-
or die(mysql_error());
-
-
mysql_query("INSERT INTO $db_table4(QualificationName) values ('$_POST[QualificationName]')")
-
or die(mysql_error());
-
-
mysql_query("INSERT INTO $db_table5(SpecializationArea) values ('$_POST[SpecializationArea]')")
-
or die(mysql_error());
-
-
mysql_query("INSERT INTO $db_table7(UserName,PhoneNo,MobileNo,YearsExp,
-
MonthsExp,FunctionalArea,KeySkills,Qualification,Specialization,Institute,
-
FunctionalRoles,CurrentEmployer,PreviousEmployers,ProfileTitle,ResumeFile)
-
values ('$_POST[UserName]','$_POST[PhoneNo]','$_POST[MobileNo]',
-
'$_POST[YearsExp]','$_POST[MonthsExp]','$_POST[AreaName]',
-
'$_POST[KeySkills]','$_POST[QualificationName]','$_POST[SpecializationArea]',
-
'$_POST[Institute]','$_POST[RoleName]','$_POST[CurrentEmployer]',
-
'$_POST[PreviousEmployers]','$_POST[ProfileTitle]','$_POST[ResumeFile]')")
-
or die(mysql_error());
-
-
mysql_query("INSERT INTO $db_table8(UserName,UserPassword,FullName,EmailAddress)
-
values ('$_POST[UserName]','$_POST[UserPassword]','$_POST[FullName]',
-
'$_POST[EmailAddress]')") or die(mysql_error()) ;
-
-
mysql_query( "INSERT INTO $db_table9(UserName)values('$_POST[UserName]')")
-
or die(mysql_error());
-
-
echo "Congrats, Your have been successfully registered on our portal";
-
-
}
-
-
?>
-
hi,
plz can anyone help me out
you use software called EasyPhp which enables the php pages to be displayed on the windows environment.
it also runs Apache and Mysql Server.
copy all your pages in the Program Files -> EasyPhp -> www folder and run the IE as http://localhost/yourfile.php
you problem will be solved.
Hi,
Thanx but i can view my pages thats not a problem.
I ve written the pages in html but i want to verify that the user during registration types the pasword and retype pasword same or not. i want the logic for this part.
Hi,
Thanx but i can view my pages thats not a problem.
I ve written the pages in html but i want to verify that the user during registration types the pasword and retype pasword same or not. i want the logic for this part.
i gave you the logic...
[php]
if(password_a == password_b)
{
// run the mysql queries
}
else
{
// the passwords didnt match
}
[/php]
Thanks alot. That logic worked but have a small problem in it. If the password doesnt match it than also stores the other info in all other tables. Also how should i send the user back to fill in the password. should i specify the html file path for it in href. I also wanted to know about making a compulsion for password strength.
Thanks again
Hi,
It is working now my that peoblem also got solved. I want that if the paswords dont match than when the user returns the registration page then he should not be asked to type all the information again. It should appear on screen and should only be asked to enter the paswords again. My other problem of pasword strength is not solved yet. Plz let me know.
Plz can anyone tel me how ro set minimum number of characters for pasword criteria in a form.
Plz can anyone tel me how ro set minimum number of characters for pasword criteria in a form.
javascript : -
function checkInput()
-
{
-
var password = document.form_name.input_name;
-
if(password.value.length < 7) // if string is less than 7 chars
-
{
-
alert("Password must be longer than 7 chars");
-
return false;
-
}
-
else if
-
{
-
// other checking ...
-
}
-
else
-
{
-
// submit form?
-
}
-
}
-
Php:
[php]
<?php
session_start(); //start up a session
$_password = $_POST['password'];
if(strlen($_password) < 6) // if length less than 6
{
$_SESSION['errors'] = "Password too short."; // give an explanation of error.
header("Location: some/directory/of/form/");
}
// other code..
[/php]
hey can u plz let me know what is the header section in the above code of PHP dt u ve put. Wt exactly is supposed to come there. Thanks
hey can u plz let me know what is the header section in the above code of PHP dt u ve put. Wt exactly is supposed to come there. Thanks
The header("Location: ... is a way of redirecting users through php.
So:
[php]
header("Location: http://somewebsite.com");
// would direct the user to somewebsite.com
header("Location: images/thumbs/img1.jpg");
// would redirect the user to the directory (on the wesbite/path this was used)
// e.g www.somesite.com/this-is-where-the-script-is/
// to www.somesite.com/this-is-where-the-script-is/images/thumbs/img1.jpg
[/php]
:)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Pugi! |
last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get
the following problem when connecting to mysql through a browser
(phpMyAdmin):
:
#2002 Can't connect to local MySQL...
|
by: ngiven |
last post by:
Hello All,
I'm running mysql 4.0.21 on an HP-UNIX machine and I am getting the
following error:
Got error 12 from Table Handler
After looking up this error in the MySQL manual,...
|
by: kamilla |
last post by:
I have a mysql 3.5 server installed on a suse linux 8.1, with address 10.0.0.100.
Now I want to access that db from a W2K pc, address 10.0.0.200.
I am able to ping 10.0.0.100, but I cannot connect...
|
by: 21novembre |
last post by:
Hi all,
I got a quite strange problem when I tried to setup a database backup
shell. I put it this way:
"bin/mysqldump --opt --user=xxx --password=xxx DB > DB.bak"
However, error 1045 came to...
|
by: dstewart |
last post by:
Situation:
One common MySQL database server on SuSE 9.1 with all updates.
Uses 'rinetd'. Has entries for the appropriate IP addresses of all
servers.
NOTE: If the appropirate entries are NOT in...
|
by: Erik H. |
last post by:
Trying to connect to MySQL db on localhost, and populate datagrid from a
dataset using code inline method.
Getting the following compile error:
Error Message: "CS0246: The type or namespace...
|
by: Jeremy Dillinger |
last post by:
I am trying to design a program that will use data from a MySQL database.
Currently all the data is being used with PHP scripts from a website. I am
also trying to build a software solution that...
|
by: coosa |
last post by:
Hi,
I was installing SQL Server on my machine and during installation my PC
freezed. It happens frequently on my machine. So i tried after
restarting to install it again and since then i always...
|
by: arsisthesis |
last post by:
Hi all,
I have a curious problem with the ERROR 1044 and 1045:
-system: OS X 10.4.3 (bash shell)
-bash schell prompt: /~ kssun$
-I have set passwd to 'kssun'
-I set path:...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |