| John Holmes 2004-12-27, 3:55 pm |
| amol patil wrote:
> hallo,
>
> see below code. query is not executing and data is not shown in table of database.after submit button hit.
>
> how to evaluate $submit true. have Tried these statements before if statement
>
> echo "--$submit--";
>
> echo "--$_POST["submit"]--";
>
> echo"Submit = $submit ";
>
> but still query is not executing.
The reason people told you to put the above code is for troubleshooting.
It's not going to fix your query. What do you actually see resulting
from the above code before and after you hit your submit button? My
crystal ball says you see this:
----
----
Submit =
Am I right?
> <?php
>
> if($submit)
> {
>
> $dbh=mysql_connect ("localhost", "root") or die ('I cannot connect to
> the database because: ' . mysql_error());
> mysql_select_db ("dollar1_allinfo");
>
> mysql_query("INSERT INTO totalinfo (Username,Password) VALUES
> ('$loginusername','$loginpassword')")or die (mysql_error());
So if you see what I guessed above, then $submit is not set, so whatever
code you have here not going to execute. Do you know how an IF
conditional works? Do you know that if it evaluates to FALSE, then
nothing within the conditional block is executed? Your query is probably
fine, but the code is just never getting to it.
I could tell you to use $_GET['submit'] or $_REQUEST['submit'], but
would you know why or where to use it?
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
|