Ask a Question related to Dreamweaver AppDev, Design and Development.
-
Bloke #1
PHP- Creating a "success" message for a form
I am working on a simple form to use as a guesbook. When the user enters thier
name, subject and commnents the meesage should read 'Your message was
submitted' ect. But when the page loads it already gives the success message
before you submit the form. What am I doing wrong? code:<?php
require_once['Connections/guestbkConn.php'); ?> <?php ini_set ('display_errors'
, 1); error_reporting (E_ALL & ~E_NOTICE); if ($dbc = @mysql_connect
(password here)) { if (!@mysql_select_db (database here)) { die (' Could not
select data base because: ' . mysql_error() . '</p>'); } } else { die ('
Could not connect to MySQL because : ' . mysql_error() . '</p>'); } $query =
'INSERT INTO blog (author, subject, comments, date) VALUES
('{$_POST['author']}','{$_POST['subject']}','{$_POST['comments']}', NOW())';
if (@mysql_query ($query)) { print ' Your message has been submitted</p>'; }
else { print ' Could not submite becuase' . mysql_error() . '. The query was
$query. </p>'; mysql_close(); } ?> Thank you for visiting my guestbook.
Please enter your comments below:<br /> <form name='form' method='post'
action='guestbk.php'> <table width='60%' border='0' cellspacing='0'
cellpadding='0'> <tr> <td>Name</td> <td><input name='author' type='text'
id='author' /></td> </tr> <tr> <td>Subject</td> <td><input name='subject'
type='text' id='subject' /></td> </tr> <tr> <td>Comments</td> <td><textarea
name='comments' id='comments'></textarea></td> </tr> <tr> <td>&nbsp;</td>
<td>&nbsp;</td> </tr> <tr> <td>&nbsp;</td> <td><input type='submit'
name='Submit' value='Submit' /> <input type='reset' name='Submit2'
value='Reset' /></td> </tr> </table> </form>
Bloke Guest
-
#39850 [NEW]: SplFileObject contradictory "failed to open stream: Success"
From: judas dot iscariote at gmail dot com Operating system: Linux 64bit PHP version: 5CVS-2006-12-16 (CVS) PHP Bug Type: SPL... -
creating a "new user" submission form
Hi I am trying to create a registration form for users to give me their info like name, username/password, billing address and shipping info. This... -
"Error Creating Control" and "Cast from String"
I'm creating a custom date control. In appearance, it's just a textbox and a button. It has three custom properties: CalDate, CalDateType and... -
Acrobat Form Submit error: changes VALUE="true" to "0"
I wrote an HTML page with a form. In the form I had many inputs as in: <INPUT TYPE="radio" NAME="Q1" VALUE="true"> and <INPUT TYPE="radio"... -
#25366 [NEW]: form buttons of type "image" dont send "submit" $_POST variable in IE
From: jordanolsommer at imap dot cc Operating system: Windows XP PHP version: 4.3.2 PHP Bug Type: Variables related Bug... -
-Rb #2
Re: PHP- Creating a "success" message for a form
"Bloke" <webforumsuser@macromedia.com> wrote in message
news:d24ij7$q09$1@forums.macromedia.com...<snip>>I am working on a simple form to use as a guesbook. When the user enters
>thier
> name, subject and commnents the meesage should read 'Your message was
> submitted' ect. But when the page loads it already gives the success message
> before you submit the form. What am I doing wrong?
Wrap the php code in an if statement, check for the form being submitted.
if(isset($_POST['Submit']))
{//process your form
}else {
// display the form
}
You should include some form validation for security.
HTH
-Rb
-Rb Guest



Reply With Quote

