Re: [GENERAL] Re:PostgreSQL and PHP - Mailing list pgsql-general
From | Jeff Davis |
---|---|
Subject | Re: [GENERAL] Re:PostgreSQL and PHP |
Date | |
Msg-id | 20000211230400.24549.qmail@web3004.mail.yahoo.com Whole thread Raw |
List | pgsql-general |
Your main problem appears to be with the following line: <form method='PUT' action='contactus.html'> I don't know what the book was trying to do exactly, but the action MUST be pointed at a file that can handle the data, ie a PHP file. Also, do not use the mthod='put', it is not part of the HTML 4.01 specification ( http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13.1 links to the specification i am talking about ). Here is my suggestion: <form method="POST" action="yourfile.php3"> where 'yourfile.php3' is a valid, existing filename that will be processed by PHP ( usually requires a '.php3' or a '.phtml' extension, but that is usually configurable ). 'POST' could be changed to 'GET', but it puts the data in the url and might not work with all browsers if you have a LOT of data (most new browsers will allow a lot, so this isn't much of a concern). Hope it works. Try using this stuff in it's most simple form before you start trying to integrate all your knowledge. -Jeff Davis PS: as for the PHP comments in the html, that was just wrong of the author. --- sheila bel <sheilabel@hotmail.com> wrote: > > Hi, I'm trying an example from a book using PHP and > PostgreSQL. > This application lets you create a form on a web > page and > have the output emailed directly to you. It also > stores the > data input into a database table. If you are not > interested in > PHP please ignore this message. > > This is the actual code : > > <?PHP > //step #2 handle the output from the form > > if ( strlen($name)>0 ): > if (strlen($email)<1): > echo "<center><b>Please enter an E-Mail > address</b> > <br>Use your browser's BACK key to > return</center>"; > exit; > endif; > > $name = addslashes($name); > $email = addslashes($email); > $phone = addslashes($phone); > $message = addslashes($message); > > $subject_field = "My Form"; > $SENDTO = "sheilabel@hotmail.com"; > > $BODY = "FROM: $name > \nPhone : $phone > \nE-Mail: $email > \nMessage: $comments"; > > mail ($SENDTO, $subject_field, $BODY, > "From:$email"); > > //save the results in our table > //open the database > > $conn=pg_Connect("","","","","mydatabase"); > if (!$conn) {echo "An error occured in > connection.\n";exit;} > > //insert a new record to store the data > > $result = pg_Exec($conn, "insert into myform > (name,phone,email,message) > VALUES ('$name', '$phone', '$email', '$message' "); > if (!$result) {echo "An error occured in > connection.\n";exit;} > > //return to the form > $CP="contactus.html"; > Header("REFRESH: 2 ; URL=$CP"); > > echo "<html><bodybgcolor=WHITE><center> > <p> <p> <p> "; > echo "<font face= \" helvetica, arial \" > color=\"#000080\">"; > echo "Your message has been<b> successfully</b> sent > to <b> $SENDTO</b>"; > echo "<br>Moving now to the <b>$CP</b> section > ...."; > echo "</center></body></html>"; > exit; > endif; > ?> > > <html> > <head> > <title>---contactus.html </title> > </head> > <body> > > //step #1 > //create the form > > <form method='PUT' action='contactus.html'> > <table> <tr><td> > Type in your Name: > <INPUT TYPE="text" NAME="name" VALUE="" SIZE=20 > MAXLENGTH=40 > > <br> > Type in your E-Mail: > <INPUT TYPE="text" NAME="email" VALUE="" SIZE=20 > MAXLENGTH=40> > <br> > Type in your Phone: > <INPUT TYPE="text" NAME="phone" VALUE="" SIZE=8 > MAXLENGTH=20> > <br> > Type in your Message: > <TEXTAREA NAME="message" ROWS=3 COLS=40 > WRAP=VIRTUAL></TEXTAREA> > <p> > <INPUT type=SUBMIT name=SUBMIT value="Press to > Submit"> > </td></tr> > </table> > </body> > </head> > > I've also created this little database: > createdb mydatabse; > create table myform(name text,email text, phone > text, message text); > > >>Now what is confusing me is why in the html code > they have > used // for commenting since it shows in the web > page. > > I've saved this file under the name example.php3 > when I view this > in the web browser as : > > http://www.myserver.com/mydirectory/example.php3 > > I see a form and I fill it out. It is supposed to > check for the email box > and if empty return an error message, it doesn't do > that. > The file is not submitted and nothing is emailed to > me. When I click > on Submit it just empties the form and does not give > me any messages > like its supposed to. > > >>If you have any idea what seems to be the problem > please let me know > since I've been struggling with this for a day now. > > Thank you for your time, > -Sheila > > ______________________________________________________ > Get Your Private, Free Email at > http://www.hotmail.com > > > ************ > > __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com
pgsql-general by date: