I have the code below but how do I submit the form to a table?

<?php
//////////////////////////////////////////
//// MySQL Database Connection ///////////
//////////////////////////////////////////
$host = "localhost";
$user = "theflick_divx";
$db_name= "theflick_divx";
$pass= "password";

$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db_name, $conn) or die(mysql_error());

//DivX Table
echo "<form id=\"divx\" name=\"divxsubmit\" method=\"post\" action=\"post\">
        <label>
          Movie Name: <input name=\"$moviename\" type=\"text\" size=\"31\" maxlength=\"30\" />
        </label>
		<br />
		<label>
          Divx Link :
          <input name=\"$divxlink\" type=\"text\" size=\"34\" maxlength=\"1000\" />
        </label>   
		<br />
		<label>
          IMDB Link:    
          <input name=\"$imdblink\" type=\"text\" size=\"33\" maxlength=\"50\" />
        </label>
		<br />
		<label>
          Image URL:    
          <input name=\"$imageurl\" type=\"text\" id=\"$imageurl\" size=\"33\" maxlength=\"100\" />
        </label> 
				<br />
		<label>
          Optional Backlink:    
          <input name=\"$backlink\" type=\"text\" size=\"27\" maxlength=\"100\" />
        </label>
		<p><label>
        <input type=\"submit\" name=\"Submit\" value=\"$sql\">
        </label>
      </p>
</form>"
?>

you have to write insert query after submit your form:
see below:

if($_SERVER['REQUEST_METHOD']=='POST') {
$qur="insert into `users`(`userid`,`password`,`email`,`title`,`fname`,`sname`,`jtitle`,`company`,`address1`, `address2`,`address3`,`town`,`postcode`,`country`,`isector`,`interests`,`telephone`,`fax`,`url`,`status`,`reg_date`)values ('".$_POST['userid']."','".$_POST['password']."','".$_POST['email']."','".$_POST['title']."','".$_POST['fname']."','".$_POST['sname']."','".$_POST['jtitle']."','".$_POST['company']."','".$_POST['address1']."','".$_POST['address2']."','".$_POST['address3']."', '".$_POST['town']."','".$_POST['postcode']."','".$_POST['country']."','".$_POST['isector']."','".$tempids."','".$_POST['telephone']."','".$_POST['fax']."','".$_POST['url']."','0', now())";
			$res= mysql_query( $qur ) ;	
}
commented: Thanks for your help - !Unreal :) +1

Ok, thanks. I will try it now :)

No luck :(

Could someone please find what is wrong with my script.

<?php
//////////////////////////////////////////
//// MySQL Database Connection ///////////
//////////////////////////////////////////
$host = "localhost";
$user = "theflick_divx";
$db_name= "theflick_divx";
$pass= "password";

$conn = mysql_connect($host, $user, $pass) or die(mysql_error());
mysql_select_db($db_name, $conn) or die(mysql_error());

//DivX submit form
echo "<form method=post name=\"divxsubmit\" target=\"_self\" id=\"divx\">
        <label>
          Movie Name: <input name=\"$moviename\" type=\"text\" value=\"$moviename\" size=\"31\" maxlength=\"30\" />
        </label>
		<br />
		<label>
          Divx Link :<input name=\"$divxlink\" type=\"text\" value=\"$divxlink\" size=\"34\" maxlength=\"1000\" />
        </label>   
		<br />
		<label>
          IMDB Link:<input name=\"$imdblink\" type=\"text\" value=\"$imdblink\" size=\"33\" maxlength=\"50\" />
        </label>
		<br />
		<label>
          Image URL:<input name=\"$imageurl\" type=\"text\" id=\"$imageurl\" value=\"$imageurl\" size=\"33\" maxlength=\"100\" />
        </label> 
				<br />
		<label>
          Optional Backlink:<input name=\"$backlink\" type=\"text\" value=\"$backlink\" size=\"27\" maxlength=\"100\" />
        </label>
		<p><label></label>
          <label>
          <input name=\"$res\" type=\"submit\" id=\"$res\" value=\"Submit\">
          </label>
	  </p>
</form>";

if($_SERVER['REQUEST_METHOD']=='POST') {
$qur="insert into `links`(`moviename`,`divxurl`,`imdb`,`imageurl`,`backlink`)values ('".$_POST['$moviename']."','".$_POST['$divxlink']."','".$_POST['$imdblink']."','".$_POST['$imageurl']."','".$_POST['$backlink']."', now())";
$res=mysql_query( $qur );	
}

?>

The names of your input are wrong. That is,

<label>
Movie Name: <input name=\"$moviename\" type=\"text\" value=\"$moviename\" size=\"31\" maxlength=\"30\" />
</label>

name=\"moviename\" and not name=\"$moviename\" Since the variables will be empty, the input tags name will be empty too.

Oh crap. I was still using the name tags from my old code.

Thanks for telling me that. :o

EDIT: Still not working :(

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.