Submit Form To MySQL Table

Thread Solved

Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

Submit Form To MySQL Table

 
0
  #1
Aug 6th, 2008
I have the code below but how do I submit the form to a table?

  1. <?php
  2. //////////////////////////////////////////
  3. //// MySQL Database Connection ///////////
  4. //////////////////////////////////////////
  5. $host = "localhost";
  6. $user = "theflick_divx";
  7. $db_name= "theflick_divx";
  8. $pass= "password";
  9.  
  10. $conn = mysql_connect($host, $user, $pass) or die(mysql_error());
  11. mysql_select_db($db_name, $conn) or die(mysql_error());
  12.  
  13. //DivX Table
  14. echo "<form id=\"divx\" name=\"divxsubmit\" method=\"post\" action=\"post\">
  15. <label>
  16. Movie Name: <input name=\"$moviename\" type=\"text\" size=\"31\" maxlength=\"30\" />
  17. </label>
  18. <br />
  19. <label>
  20. Divx Link :
  21. <input name=\"$divxlink\" type=\"text\" size=\"34\" maxlength=\"1000\" />
  22. </label>
  23. <br />
  24. <label>
  25. IMDB Link:
  26. <input name=\"$imdblink\" type=\"text\" size=\"33\" maxlength=\"50\" />
  27. </label>
  28. <br />
  29. <label>
  30. Image URL:
  31. <input name=\"$imageurl\" type=\"text\" id=\"$imageurl\" size=\"33\" maxlength=\"100\" />
  32. </label>
  33. <br />
  34. <label>
  35. Optional Backlink:
  36. <input name=\"$backlink\" type=\"text\" size=\"27\" maxlength=\"100\" />
  37. </label>
  38. <p><label>
  39. <input type=\"submit\" name=\"Submit\" value=\"$sql\">
  40. </label>
  41. </p>
  42. </form>"
  43. ?>
Last edited by !Unreal; Aug 6th, 2008 at 12:44 am.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,073
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: Submit Form To MySQL Table

 
1
  #2
Aug 6th, 2008
you have to write insert query after submit your form:
see below:
  1. if($_SERVER['REQUEST_METHOD']=='POST') {
  2. $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())";
  3. $res= mysql_query( $qur ) ;
  4. }
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

Re: Submit Form To MySQL Table

 
0
  #3
Aug 6th, 2008
Ok, thanks. I will try it now
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

Re: Submit Form To MySQL Table

 
0
  #4
Aug 6th, 2008
No luck

Could someone please find what is wrong with my script.

  1. <?php
  2. //////////////////////////////////////////
  3. //// MySQL Database Connection ///////////
  4. //////////////////////////////////////////
  5. $host = "localhost";
  6. $user = "theflick_divx";
  7. $db_name= "theflick_divx";
  8. $pass= "password";
  9.  
  10. $conn = mysql_connect($host, $user, $pass) or die(mysql_error());
  11. mysql_select_db($db_name, $conn) or die(mysql_error());
  12.  
  13. //DivX submit form
  14. echo "<form method=post name=\"divxsubmit\" target=\"_self\" id=\"divx\">
  15. <label>
  16. Movie Name: <input name=\"$moviename\" type=\"text\" value=\"$moviename\" size=\"31\" maxlength=\"30\" />
  17. </label>
  18. <br />
  19. <label>
  20. Divx Link :<input name=\"$divxlink\" type=\"text\" value=\"$divxlink\" size=\"34\" maxlength=\"1000\" />
  21. </label>
  22. <br />
  23. <label>
  24. IMDB Link:<input name=\"$imdblink\" type=\"text\" value=\"$imdblink\" size=\"33\" maxlength=\"50\" />
  25. </label>
  26. <br />
  27. <label>
  28. Image URL:<input name=\"$imageurl\" type=\"text\" id=\"$imageurl\" value=\"$imageurl\" size=\"33\" maxlength=\"100\" />
  29. </label>
  30. <br />
  31. <label>
  32. Optional Backlink:<input name=\"$backlink\" type=\"text\" value=\"$backlink\" size=\"27\" maxlength=\"100\" />
  33. </label>
  34. <p><label></label>
  35. <label>
  36. <input name=\"$res\" type=\"submit\" id=\"$res\" value=\"Submit\">
  37. </label>
  38. </p>
  39. </form>";
  40.  
  41. if($_SERVER['REQUEST_METHOD']=='POST') {
  42. $qur="insert into `links`(`moviename`,`divxurl`,`imdb`,`imageurl`,`backlink`)values ('".$_POST['$moviename']."','".$_POST['$divxlink']."','".$_POST['$imdblink']."','".$_POST['$imageurl']."','".$_POST['$backlink']."', now())";
  43. $res=mysql_query( $qur );
  44. }
  45.  
  46. ?>
Last edited by !Unreal; Aug 6th, 2008 at 2:38 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 3,760
Reputation: nav33n is a jewel in the rough nav33n is a jewel in the rough nav33n is a jewel in the rough 
Solved Threads: 332
Moderator
Featured Poster
nav33n's Avatar
nav33n nav33n is offline Offline
Senior Poster

Re: Submit Form To MySQL Table

 
0
  #5
Aug 6th, 2008
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.
Ignorance is definitely not bliss!

*PM asking for help will be ignored*
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 112
Reputation: !Unreal is an unknown quantity at this point 
Solved Threads: 2
!Unreal's Avatar
!Unreal !Unreal is offline Offline
Junior Poster

Re: Submit Form To MySQL Table

 
0
  #6
Aug 6th, 2008
Oh crap. I was still using the name tags from my old code.

Thanks for telling me that. :o

EDIT: Still not working
Last edited by !Unreal; Aug 6th, 2008 at 3:12 am.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC