Jump to content

Submit Button Problem


Sturm

Recommended Posts

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! :)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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? :-\

Link to comment
Share on other sites

<?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

Link to comment
Share on other sites

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'

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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');
}
?>

Link to comment
Share on other sites

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');
}
?>

Link to comment
Share on other sites

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... :-[

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.