Go Back   CodingForums.com > :: Client side development > JavaScript programming

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 08-21-2007, 05:47 PM   PM User | #1
thindrakhya
New Coder

 
thindrakhya's Avatar
 
Join Date: Jun 2007
Posts: 90
Thanks: 8
Thanked 0 Times in 0 Posts
thindrakhya can only hope to improve
passing javascript variables to php

hi all

i am changing the variable value through javascript button click eg

function setMode()
{
document.FrmMaster.hidEditVariable.value='DC';

document.FrmMaster.submit();
}


this works fine when i am using on localt host using apache
now i have uploaded the files on godaddy and my variables like
hideditvariable is not chnaged when i click on the buttons
i don't know what setting needs to be changed for webserver as it works on loal host

one thing more ,
initially i was using variables like $abc on php
but this did'nt work on godaddy i had to use $_GET["abc"] to work on godaddy
i dont' know why?
thindrakhya is offline   Reply With Quote
Old 08-21-2007, 09:06 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,686
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
Without the rest of your script there's no way of knowing why it wouldn't be working.

Using $abc rather than $_GET['abc'] is bad practice because of what you experienced; a server can turn register_globals off (because it can be a massive security hole) and your script breaks. So it's obviously better to specify $_GET['abc'] as a standard.
__________________
Fumigator is offline   Reply With Quote
Old 08-22-2007, 05:17 PM   PM User | #3
thindrakhya
New Coder

 
thindrakhya's Avatar
 
Join Date: Jun 2007
Posts: 90
Thanks: 8
Thanked 0 Times in 0 Posts
thindrakhya can only hope to improve
hi this is

testing1.html

Quote:
<html>
<body>

<SCRIPT language="JavaScript">
function setMode()

{


document.form1.var1.value='D';
document.form1.submit();

}

</script>

<form ACTION = "testing1.php" METHOD = post NAME = "form1" >

<input name = "var1" type = "hidden" value = "B">
<input type ="button" onClick = "setMode();" value = "Enter Information">

</form>
</body>
</html>


and this is
testing1.php


Quote:
<?php
echo($var1); or echo($_GET["var1"]);
?>




Now When i run on my local host this runs fine but when i run on my godaddy server the output is nill, i dont' know why




one thing more i have tested by simly echoing the value of hidden variable var
i.e without this

Quote:
document.form1.var1.value='D';
even then i am not getting the output on godaddy server

Last edited by thindrakhya; 08-22-2007 at 05:22 PM..
thindrakhya is offline   Reply With Quote
Old 08-22-2007, 05:28 PM   PM User | #4
thindrakhya
New Coder

 
thindrakhya's Avatar
 
Join Date: Jun 2007
Posts: 90
Thanks: 8
Thanked 0 Times in 0 Posts
thindrakhya can only hope to improve
Ok friends found the ****ing problem
had to use

$_REQUEST rather than $_GET

Can anyone tell whats the difference
thindrakhya is offline   Reply With Quote
Old 08-22-2007, 11:52 PM   PM User | #5
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,686
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
You can determine whether to use $_GET or $_POST by choosing "get" or "post" as your form's method.

You have:
Code:
<form ACTION = "testing1.php" METHOD = post NAME = "form1" >
Your form is method="post" so your form elements will be available in the $_POST array in PHP when it is submitted. Both $_GET and $_POST arrays are also defined in the $_REQUEST array but I always prefer using $_GET or $_POST for clarity.
__________________
Fumigator is offline   Reply With Quote
Old 08-24-2007, 04:40 AM   PM User | #6
thindrakhya
New Coder

 
thindrakhya's Avatar
 
Join Date: Jun 2007
Posts: 90
Thanks: 8
Thanked 0 Times in 0 Posts
thindrakhya can only hope to improve
thanks dude
thindrakhya 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:14 AM.


Advertisement
Log in to turn off these ads.