hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : Very annoying php bug
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

Very annoying php bug

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-12-2002, 02:42 AM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249

Very annoying php bug


Essentially I'm attempting to quasi mimic the effect of phpMyAdmin. When you activate the checkbox after you click submit it will return to the previous page to re-enter another item

Input Page
PHP Code:
<center>
<form action="secured.php">
    <input type="hidden" name="loc" value="cars">
    <input type="hidden" name="sloc" value="choose_model">
    <input type="hidden" name="s2loc" value="create_model">
    <input type="hidden" name="manu" value="<?echo $manu?>">
    <input type="text" name="new_model" class="form"><br>

    <div class="main">Insert New Model After Insert

    <input type="checkbox" name="insertnew" <?echo $insert_again?> value="setnew" class="form">

</div>
    <input type="submit" value="Create New Model" class="button_nowidth">
</form>
</center>
And.. The result page. It enters the information into the DB then determines if the checkbox was checked then includes a "meta" tag to refresh back to the previous page... But, php refuses to accept the information passed to it in the check box... I didn't want to clean up my debugging code b/c it shows what I have already tried to get the variable to show up in the second page
PHP Code:
$sql = "INSERT INTO `car_model` VALUES ('', '$manu', '$new_model')";
    //$res = mysql_query($sql);


    echo "<br>"."--".$insertnew."--";


    if (isset($insertnew))
    {
        ?><META HTTP-EQUIV=Refresh CONTENT="0; URL=secured.php?loc=cars&sloc=choose_model&manu=$manu&insert_again=checked"><?
    
}
    if (
$insertnew == true)
        echo 
"testing";
    if (
$insertnew)
        echo 
"boolean";
    if (
$insertnew == "on")
        echo 
"on";

    if (
$insertnew == "setnew")
        echo 
"setnew";
When run... Nothing is echoed by the if statements and $insertnew echo's blank...
The page output at the echo "--".$insertnew."--" prints out as "----"....


Anyone have any clues about to why this isn't working?
I can provide for enviroment details about whats going on if need be...

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

Reply With Quote


Sponsored Links
  #2  
Old 09-12-2002, 04:26 AM
RackNine RackNine is offline
Web Hosting Master
 
Join Date: May 2002
Location: Edmonton, Canada
Posts: 978
Simple stuff first, you did extract($_POST) first, correct? Set the form's method="POST".

-Matt

__________________
Matt Meier, RackNine Inc.
email: mmeier@racknine.com
web: http://www.racknine.com

Reply With Quote
  #3  
Old 09-12-2002, 04:27 AM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
Depending on what version of PHP you are using and whether register_globals is off in php.ini.

However you should be using the super global arrays for form variables.

i.e. call $_POST['insertnew'] rather than $insertnew (and if your form is a get form use $_GET['insertnew']

Reply With Quote
Sponsored Links
  #4  
Old 09-12-2002, 04:50 AM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249
echo "--".$_GET["insertnew"]."--"; will display the results...

What is the difference btwn GET and POST?
Why would the variables register differently?
What is the different syntax b/twn GET & POST in the <form> tag?

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

Reply With Quote
  #5  
Old 09-12-2002, 07:13 AM
Rich2k Rich2k is offline
Web Hosting Master
 
Join Date: May 2002
Location: UK
Posts: 2,994
A GET post is the protocol you use whenever you call a normal webpage like this. You will see lots of queries on the URL of the page. This is a GET

A post hides this information so that it doesn't appear in the URL. This is most certainly the best way when you are submitting usernames and passwords as the URL can't be copied and pasted.

However you should really define the method in your form to make good HTML. either add

method="get" or method="post" to your form tag

Reply With Quote
  #6  
Old 09-12-2002, 04:14 PM
Studio64 Studio64 is offline
Web Hosting Master
 
Join Date: Jan 2002
Location: Atlanta, GA
Posts: 1,249
Thank you...

__________________
char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 }main (){void (*f)() = x;f();}
I wear a gray hat

Reply With Quote
Reply

Related posts from TheWhir.com
Title Type Date Posted
DDoS Protection - A New and Simple Technology to Protect your Infrastructure and Customers Webinars 2012-12-19 16:58:45
Web Optimization Provider Yottaa Launches Version 2.0, Adds Patented QuickTune Technology Web Hosting News 2012-09-17 15:18:17


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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 Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?