Re: This is weird..whts the prob???
| From: | Brent Baisley | Date: | Fri, 05 Nov 2004 14:21:00 +0000 |
| Subject: | Re: This is weird..whts the prob??? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201283@lists.php.net to get a copy of this message | ||
The code looks fine to me. You may want to look at the Apache access logs to see what is getting submitted to the server when you submit the form. Or you can use a network monitoring tool to see what the client is submitting.
But, if you can't figure out what is causing the problem, just use $_REQUEST instead of $_POST or $_GET. $_REQUEST doesn't care if the form was submitted via post or get, it holds the values of either type of submission.
Personally, I always like to fix the cause rather than treat the symptom. But there isn't always time in the short term.
On Nov 5, 2004, at 7:25 AM, Aalee wrote:
Hi guys, Working on PHP ver 4.3.8 with register_globals turned OFF and Apache 1.3.31. MySQL ver 4.0.20a on winXP pro SP1. This script does not seems to work with the method of POST. When I change it to GET method the data is entered into the database, but with POST it does not. I have another script with the POST method, but that script works with POST. What is wrong with this script. Here goes the script. What am I doing wrong. <?php if (isset($_GET['addjoke'])){ ?> <form name="form1" method="post" action="<?php $_SERVER['PHP_SELF']; ?>"> Type your joke :<br> <textarea name="jokeText" id="jokeText"></textarea> <br> <input name="insert" type="submit" id="submit" value="Insert Joke"> </form> <?php } else { // start main else statement if(isset ($_POST['insert'])) { $db = mysql_connect("localhost","homesite","ju4754") ; mysql_select_db("jokes",$db); $query = mysql_query("INSERT INTO jokes SET JokeText = '".$_POST['jokeText']."' , JokeDate = CURDATE() "); echo $query; echo " Joke inserted, Thank you <BR><BR>"; echo mysql_error(); } $color1 = "#66CCFF"; $color2 = "#66CC99"; $row_count = 1; // ---------- Following lines list the jokes in the database ---------------- echo "<b><H3> These are the jokes we have got so far</H3></B>"; $db = mysql_connect("localhost","homesite","ju4754") or die(mysql_error()); mysql_select_db("jokes",$db); $sql = "SELECT id, JokeText, JokeDate from jokes"; $query = mysql_query($sql); echo "<table border=1> <tr><td><b>ID<b></td><td><b>Joke Text<b></td> <td><b>Joke Date<b></td></tr>"; while ($myrow = mysql_fetch_array($query)) { $row_color = ($row_count % 2) ? $color1 : $color2; echo"<tr bgcolor = $row_color>". "<td>". $myrow["id"]."</td>". "<td>". $myrow["JokeText"]. "</td>". "<td>". $myrow["JokeDate"]."</td></tr>"; $row_count++; } echo "</table>"; $current_url = $_SERVER['PHP_SELF']; echo("<P><A HREF=".$current_url."?addjoke=1>" ."Add a Joke!</A></P>"); } // end main else statement ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577