Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Tue Oct 19, 2004 12:50 pm
hey, im trying to make a form that sends the users input to the mysql server..
ive got the following(i also need something that can check if everything is filled and if not, abort the submit and let the user know
Code: Select all
echo '<form method="post" enctype="text/plain" action=' . '><p>Your Username: <input name=author maxlength="30"> <p>Your Email Adress: <input name=email>
<p>Title: <input name=title maxlength="40"> <p> <p>Text: <br> <textarea name=why rows=5 cols=60></textarea> <p> <input type=SUBMIT value=Submit
name="SUBMIT"> <input type=RESET value="Clear All" name="RESET"></form>';
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Oct 19, 2004 1:58 pm
[devnet]+form +valid*[/devnet] and [mysql_man]INSERT Syntax[/mysql_man]
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Tue Oct 19, 2004 2:01 pm
well... i know i gotta use $_POST['text'] and stuff.. but i just dont know when to activate it or something.. and for the form + valid thing i dont understand, it searches for a post with +form valid in it, but it doesnt find one..
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Oct 19, 2004 2:03 pm
it finds 630 threads involving those two, right now.
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Tue Oct 19, 2004 2:10 pm
well
i dont really need to validate them.. i only need to check if they are empty :/
but i dont really have any experience with forms
still cant get the form to work
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Tue Oct 19, 2004 2:51 pm
Bump (ill delete this post)
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Oct 19, 2004 2:54 pm
please do not bump your thread only 40 minutes after your last post.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Tue Oct 19, 2004 2:54 pm
Diod wrote: Bump (ill delete this post)
its only been 41 minutes. Be patient for replies. If you require immediate assistance visit #php on freenode (IRC)
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Tue Oct 19, 2004 2:55 pm
ok ill go to the channel
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Wed Oct 20, 2004 9:28 am
need some help with my form.. (got it to work)
i got the form to work, but it doesnt insert the correct date and time(both current)
i want the date to be inserted into a TIMESTAMP row
i want the time to be inserted into a TIME row
i got the following code
Code: Select all
printf('<div align="center">');
echo "Add a news post.";
echo '<form method="post">';
echo '<input type="hidden" name="submit" value="true">';
echo '<p>Your Username: <input type="text" name="author" maxlength="30"></p>';
echo '<p>Your Email Adress: <input type="text" name="email"></p>';
echo '<p>Title: <input type="text" name="title" maxlength="40"></p>';
echo '<p>Text: <br> <textarea name="text" rows="5" cols="60"></textarea></p>';
echo '<p><input type="submit" value="Submit"><input type="reset" value="Clear All">';
echo '</form>';
if (isset($_POST['submit']))
{
$query = 'INSERT ' . 'INTO news (text, author, email, date, time, title) VALUES(''' . $_POST['text'] .''', ''' . $_POST['author'] .''', ''' . $_POST['email'] . ''', '''. time() . ''', '''. time() . ''', ''' . $_POST['title'] . ''')';
$result = mysql_query($query,$db);
if ($result)
{
echo '<br>News Added Succesfully<br/>';
}
}
feyd | correct code to post just fine. :roll::roll::roll::roll:
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Wed Oct 20, 2004 9:34 am
you corrected what in my code? :/
thx anyway =-)
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Oct 20, 2004 9:34 am
use the mysql function: [mysql_man]NOW()[/mysql_man]
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Wed Oct 20, 2004 9:40 am
now i get
Code: Select all
Warning: date() їfunction.date]: Windows does not support dates prior to midnight (00:00:00), January 1, 1970 in c:\AppServ\www\index.php on line 22
Title: ssdgsdg | Author: gs | 838:59:59 Hours
-----------------------
ssdsggd
and i DID use NOW()
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Oct 20, 2004 9:41 am
you aren't using [mysql_man]NOW()[/mysql_man] you're using [php_man]time()[/php_man].. big difference.
Diod
Forum Commoner
Posts: 52 Joined: Tue Oct 19, 2004 9:07 am
Post
by Diod » Wed Oct 20, 2004 9:49 am
nope, im using
Code: Select all
{
$query = 'I-N-SERT INTO news (text, author, email, date, time, title) VALUES(''' . $_POST['text'] .''', ''' . $_POST['author'] .''', ''' . $_POST['email'] . ''', '''. 'NOW()' . ''', '''. time() . ''', ''' . $_POST['title'] . ''')';
$result = mysql_query($query,$db);