Sturm Posted May 29, 2007 Share Posted May 29, 2007 hi everybody.i need help with a submit button.i want to have 3 submit fields,and a submit button,please tell me how to do this.my other question is how to connect this submit button info,to be written in a table in my Database.i have 3 fields in the table in my DB-"number", "comment" and |"date",if this could be of any help.please justt tell me the code,because i have very little time to do this,my computer is at stake! :'( if i had more time,i wouldn't have asked you. if you have any other questions,write here Thank you VERY MUCH! Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/ Share on other sites More sharing options...
Sturm Posted May 29, 2007 Author Share Posted May 29, 2007 please help :'( Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264101 Share on other sites More sharing options...
eric1235711 Posted May 29, 2007 Share Posted May 29, 2007 I didn't understand what you really want Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264149 Share on other sites More sharing options...
snowdog Posted May 29, 2007 Share Posted May 29, 2007 Here is what I would do. Html input form (input.html) <form method="POST" name="insert_into_database" action="insert_into_database.php"> <td><input type="text" name="number" value="" size="2"></td> <td><input type="text" name="comment" value="" size="2"></td> <td><input type="text" name="date" value="" size="2"></td> <input type="submit" name="submit" value="submit"> </form> insert_into_database.php code $number = $_REQUEST['number']; $comment = $_REQUEST['comment']; $date = $_REQUEST['date']; $query = "INSERT INTO databse(number,comment,date) VALUES('$number','$comment','$date')"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); Snowdog Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264164 Share on other sites More sharing options...
Sturm Posted May 29, 2007 Author Share Posted May 29, 2007 snowdog,i have only 1 question.the submit button has to put them in the TABLE,in the DATABASE.and i have config.php with all the info fot my MYSQL_HOST,PASS,ACC etc.dont i have to put include in the html so it knows what the server and username etc. are? :-\ Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264169 Share on other sites More sharing options...
per1os Posted May 29, 2007 Share Posted May 29, 2007 <?php include('config.php') // needed for db connection. if (isset($_REQUEST['submit'])) { $number = $_REQUEST['number']; $comment = $_REQUEST['comment']; $date = $_REQUEST['date']; $query = "INSERT INTO databse(number,comment,date) VALUES('$number','$comment','$date')"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); } else { die('No data was passed in'); } ?> I think snowdog just layed out a foundation for you, very nice of him, of course you need the connection etc included in that file. Without it how does the DB make a connection, the db does not need to be in the input.html unless you want it to, at which it would no longer be index.html it would be index.php as php can only run on php pages unless your server is configured right Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264170 Share on other sites More sharing options...
snowdog Posted May 29, 2007 Share Posted May 29, 2007 Well sure you have to. But I wasnt going to write the enitre code for you, just the part you were not understanding Snowdog Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264171 Share on other sites More sharing options...
eric1235711 Posted May 29, 2007 Share Posted May 29, 2007 well, I just wouldn't do <input type="submit" name="submit" value="submit"> because of Javascript's headaches... this is better: <input type="submit" name="insert_button" value="submit"> or anything different from just 'submit' Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264172 Share on other sites More sharing options...
AndyB Posted May 29, 2007 Share Posted May 29, 2007 well, I just wouldn't do <input type="submit" name="submit" value="submit"> because of Javascript's headaches... this is better: <input type="submit" name="insert_button" value="submit"> or anything different from just 'submit' I think that deserves an explanation since it's counter-intuitive. What headache are you talking about? Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264246 Share on other sites More sharing options...
per1os Posted May 29, 2007 Share Posted May 29, 2007 well, I just wouldn't do <input type="submit" name="submit" value="submit"> because of Javascript's headaches... this is better: <input type="submit" name="insert_button" value="submit"> or anything different from just 'submit' I think that deserves an explanation since it's counter-intuitive. What headache are you talking about? Agreed, I never had a headache when using javascript with submit buttons named submit... Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264249 Share on other sites More sharing options...
Sturm Posted May 30, 2007 Author Share Posted May 30, 2007 ... http://www.vazov.net/php2/insert_into_database.php it gives me this error,everything else works like a charm.please help for this error. Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264932 Share on other sites More sharing options...
redarrow Posted May 30, 2007 Share Posted May 30, 2007 post line 4 ok Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264934 Share on other sites More sharing options...
Sturm Posted May 30, 2007 Author Share Posted May 30, 2007 post line 4 ok Parse error: syntax error, unexpected T_IF in /home/www/vazov.net/php2/insert_into_database.php on line 4 ??? :'( ??? :'( Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264938 Share on other sites More sharing options...
redarrow Posted May 30, 2007 Share Posted May 30, 2007 post the page insert_into_database ok. Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264943 Share on other sites More sharing options...
Sturm Posted May 30, 2007 Author Share Posted May 30, 2007 post the page insert_into_database ok. <?php include('config.php') // needed for db connection. if (isset($_REQUEST['submit'])) { $number = $_REQUEST['number']; $comment = $_REQUEST['comment']; $date = $_REQUEST['date']; $query = "INSERT INTO databse(number,comment,date) VALUES('$number','$comment','$date')"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); } else { die('No data was passed in'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264951 Share on other sites More sharing options...
redarrow Posted May 30, 2007 Share Posted May 30, 2007 give this a go hay? <?php include('config.php'); // needed for db connection. if ($_GET['submit']) { $number = $_GET['number']; $comment = $_GET['comment']; $date = $_GET['date']; $query = "INSERT INTO databse(number,comment,date) VALUES('$number','$comment','$date')"; $result = mysql_query($query) or die('Query failed: ' . mysql_error()); } else { die('No data was passed in'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264953 Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 <?php include('config.php'); // semicolon needed here. Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264955 Share on other sites More sharing options...
Sturm Posted May 30, 2007 Author Share Posted May 30, 2007 <?php include('config.php'); // semicolon needed here. Semicolon...? write it for me Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264974 Share on other sites More sharing options...
per1os Posted May 30, 2007 Share Posted May 30, 2007 <?php include('config.php'); // semicolon needed here. Semicolon...? write it for me I did...do you not see the semicolon after ') ??? Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264980 Share on other sites More sharing options...
Sturm Posted May 30, 2007 Author Share Posted May 30, 2007 Warning: mysql_query() [function.mysql-query]: Access denied for user 'anastasov'@'82.197.131.40' (using password: NO) in /home/www/vazov.net/php2/insert_into_database.php on line 10 Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/www/vazov.net/php2/insert_into_database.php on line 10 Query failed: Access denied for user 'anastasov'@'82.197.131.40' (using password: NO) it gives me this error,with the semicolon red,you're way,didnt work either.it gave me an error.sorry... can somebody please help me with this...? :-\ thanks to everybody,keep triyng... Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-264991 Share on other sites More sharing options...
Sturm Posted May 30, 2007 Author Share Posted May 30, 2007 Notice: Undefined index: submit in /home/www/vazov.net/php2/insert_into_database.php on line 4 No data was passed in red,this is your way,it gave me an error Quote Link to comment https://forums.phpfreaks.com/topic/53445-submit-button-problem/#findComment-265001 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.