execution for form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
stevengoh
Forum Newbie
Posts: 5
Joined: Tue Nov 06, 2007 3:23 pm

execution for form

Post by stevengoh »

Hello everyone can check with you how to code the "2." one. I have a form that will sent the $going to execution, but unfortunately the below code not working.

Code: Select all

 
1.<input name=going> -------form
 
2.mysql_query ("insert into $going (description,  ---------action

http://www.phpbb.com/community/viewtopi ... 6&t=950035
LonelyProgrammer
Forum Contributor
Posts: 108
Joined: Sun Oct 12, 2003 7:10 am

Re: execution for form

Post by LonelyProgrammer »

You have to check for if submit is set in $_POST first.

Code: Select all

if (isset($_POST["submit"]))...
Of course, it depends on the name you choose for your form. I recommend using a hidden field instead...

Code: Select all

<form....>
<input type="hidden" name="register_submit" value="1">
</form>

if (isset($_POST["register_submit")) { 
 // perform action
}
stevengoh
Forum Newbie
Posts: 5
Joined: Tue Nov 06, 2007 3:23 pm

Re: execution for form

Post by stevengoh »

thank for reply but i did put the _POST[action] but once i change to $going then the code don't seen to work ...

Code: Select all

<?php
 
include 'config2.php';
if($_POST[action]=="Submit")
{
 
        mysql_query ("insert into [u]$going [/u](description, imgdata, username, password) values (\"".
         $_REQUEST[description].
        "\", \"".
        $_FILES['imagefile']['name'].
        "\", '$_REQUEST[user]', '$_REQUEST[pass]')");
        
        
         
}
 
 
?>
 
 
<html>
 
<head>
 
<title>Swim25.com</title>
 
</head>
 
<body>
 
 
                 
                      <?php 
if(!$action) 
{
?>
                      
                    <br> <form name="form" enctype="multipart/form-data" action="<?php print $PHP_SELF ?>" method="post">
                      <table width="100%" border="0" cellspacing="3" cellpadding="5" align="center">
                        <tr> 
                       
Please input images name <input type=file name=imagefile><br>
Please enter the description <input name=description><br>
Please input sql <input name=going><br>
User name <input type="text" name="user" value=""><br>
Password <input type="password" name="pass" value=""><br><br>
 
 
 
 
                        </tr>
 
                        <tr> 
                          <td align="center" colspan="2"><input type="submit" name="action" value="Submit"></td>
                        </tr>
 
 
                      </table>
                    </form>
                                          
</body>
 
</html>
Post Reply