Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-09-2009, 06:31 PM   PM User | #1
Killermud
Regular Coder

 
Join Date: Mar 2009
Location: United Kingdom
Posts: 161
Thanks: 6
Thanked 28 Times in 28 Posts
Killermud is on a distinguished road
Form will not submit

Hi im trying to have a form that will submit data into my database.

Unfortantly i try submitting the data and the if statement i use doesnt pick up that the button has been pressed.

PHP Code:
    <table>
        <tr><form action="" method="post">
        <td>
        Catergory Name
        </td>
        <td><input name="catname" id="catname" type="text">
        </td>
        </tr>
        <tr>
        <td><input name="catadd" id="catadd" type="submit" value="Add new Catergory"></td>
        </tr></form>
        </table>
        <?
        
}
        if(isset(
$_POST['catadd'])){
            
            
$catname=$_POST['catname'];
            echo 
"worked";
            
$sql="INSERT INTO forums forum_title='$catname' forum_type='1'";
            
$result=mysql_query($sql);
I added 'echo "worked"' so that i could tell if its the if statement or the SQL statement but, i do not see 'worked' appear, which states its the if statement or the form. But i cannot figure where it goes wrong.
Killermud is offline   Reply With Quote
Old 03-09-2009, 06:40 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
Add echo "<pre>".print_r($_POST,true)."</pre>"; to the very top of the script and see what that shows you.
__________________
Fumigator is offline   Reply With Quote
Old 03-09-2009, 06:54 PM   PM User | #3
Leppy
New Coder

 
Join Date: Jul 2007
Posts: 26
Thanks: 1
Thanked 0 Times in 0 Posts
Leppy is an unknown quantity at this point
Remove the action="" in your <form>, just don't add it at all to see if it does anything different. If it still doesn't work add the following:

PHP Code:
<form action="<?php echo $_SERVER['REQUEST_URI']; ?>"...
__________________
-
Leppy is offline   Reply With Quote
Old 03-09-2009, 07:56 PM   PM User | #4
Killermud
Regular Coder

 
Join Date: Mar 2009
Location: United Kingdom
Posts: 161
Thanks: 6
Thanked 28 Times in 28 Posts
Killermud is on a distinguished road
ok Fumigator i did that and this is what came up.

Array
(
[forumtype] => 1
[forumsubmit] => Submit
)
i had to put it before my if statement because it would not do anything otherwise.

Leppy, even with that code it still doesnt work.

EDIT: Ok solved it, it was further up my code. It was inside another if statment and that seemed to cause a problem.

Last edited by Killermud; 03-09-2009 at 08:08 PM..
Killermud is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:17 AM.


Advertisement
Log in to turn off these ads.