I'm trying to insert a simple input form into one of my pages, where should the form action attribute be looking for the php file; in other words, where do I need to put it? My web host has the WP folder inside public_html.
<form action="insert.php" method="post">
Value1: <input type="text" name="field1-name" />
Value2: <input type="text" name="field2-name" />
Value3: <input type="text" name="field3-name" />
Value4: <input type="text" name="field4-name" />
Value5: <input type="text" name="field5-name" />
<input type="Submit" /></form>
<?php$username="username";
$password="password";$database="your_database";
$field1-name=$_POST['Value1'];
$field2-name=$_POST['Value2'];
$field3-name=$_POST['Value3'];
$field4-name=$_POST['Value4'];
$field5-name=$_POST['Value5'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query = "INSERT INTO tablename VALUES('','$field1-name','$field2-name',
'$field3-name','$field4-name','$field5-name')";mysql_query($query);mysql_close();?>
Aucun commentaire:
Enregistrer un commentaire