Solved: Integrating PHP and HTML
Moderator: General Moderators
Solved: Integrating PHP and HTML
Hi,
I want to call a php code from a html "submit" button.
I write the following code:
<form action="insert.php" method="post">
....
</form>
but the insert.php file is opened and is not executed.
I want that to be executed.
Is there anything wrong or something I have to add
Thank you in advance
I want to call a php code from a html "submit" button.
I write the following code:
<form action="insert.php" method="post">
....
</form>
but the insert.php file is opened and is not executed.
I want that to be executed.
Is there anything wrong or something I have to add
Thank you in advance
Last edited by Elton on Thu Dec 14, 2006 5:51 am, edited 3 times in total.
Re: Integrating PHP and HTML
in the insert.php, you have to have $_POST['']
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
feyd | Please use
so $_POST exists there.
Do u mean I have to add at the end of the file again?
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Than you for the fast response.
The insert.php is as following:Code: Select all
<?
$username="username";
$password="password";
$database="your_database";
$first=$_POST['first'];
$last=$_POST['last'];
$phone=$_POST['phone'];
$mobile=$_POST['mobile'];
$fax=$_POST['fax'];
$email=$_POST['email'];
$web=$_POST['web'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO contacts VALUES ('','$first','$last','$phone','$mobile','$fax','$email','$web')";
mysql_query($query);
mysql_close();
?>Do u mean I have to add at the end of the file again?
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]When I click at Submit button, the insert.php is just opened.
Nothing happens at mysql Db
I am expecting one row to be inserted.
I think php is enabled.
If not, how can I enable that?
(just want to add that I am not very familiar with php
)
Additional info:
I have installed xamp and I can see apache and mysql running and my os is win Xp Professional SP2
Nothing happens at mysql Db
I am expecting one row to be inserted.
I think php is enabled.
If not, how can I enable that?
(just want to add that I am not very familiar with php
Additional info:
I have installed xamp and I can see apache and mysql running and my os is win Xp Professional SP2
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
use '<?php' rather than '<?' as short tags may be off as part of your settings.
May show php errors.
In cases like this I often just insert a debug echo in to ensure things are getting to a location... like
If the 'bleep' shows you know the php code is executing at that point.
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
?>In cases like this I often just insert a debug echo in to ensure things are getting to a location... like
Code: Select all
<?php
echo 'bleep<br />';
$username="username";
$password="password";
$database="your_database";