Submit and Value ...

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
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

Submit and Value ...

Post by egturnkey »

Hello friends,

let us cosider

Code: Select all

$a[1]['en'] = "ok";
and we have a form with submit option as following


Code: Select all

 
<form method=post>
<tr>
    <td>name :</td>
    <td><input type=text name=PlanName></td>
</tr>
 
<tr>
<td><input type=submit name=submit value="xx"></td>
</tr>
</form>
 


and its php code

Code: Select all

 
if(isset($submit) && $submit == 'xx')
{
$q1 = "insert into table set
name = \"$name\" ";
mysql_query($q1) or die(mysql_error());
}
 



at the php code ($submit) is xx
at the html code (value) is xx


NOW THE PROBLEM

when i exchange xx with $a[1]['en'] = "ok";

where i write in PHP CODE

Code: Select all

if(isset($submit) && $submit == '{$a[957][$lang]}')
and in HTML CODE

Code: Select all

<input type=submit name=submit value="<? echo $a[1][$lang]; ?>">

it didn't works

so how can i make value and submit the same using that lang variables

Code: Select all

$a[1]['en'] = "ok";

thanks in advance
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Submit and Value ...

Post by markusn00b »

egturnkey wrote:Hello friends,

let us cosider

Code: Select all

$a[1]['en'] = "ok";
[...]

thanks in advance
Strings enclosed in single quotes will not be parsed for variables within them, unlike double quotes that do parse the string. So, when you say if(isset($submit) && $submit == '{$a[957][$lang]}'), PHP will be seeing the $submit is equal to the literal string '{$a[957][$lang]}'. You can opt to change the single quotes to double quotes, or completely omit the quotes. In either choice, however, you can do rid of the {} brackets as there is no ambiguity in the expression.

Hope this helps,
Mark.

P.S. Are you using register_globals? If so, you shouldn't be!
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

Re: Submit and Value ...

Post by egturnkey »

markusn00b :D thanks very much

it helps me a lot and now i do understand how it should be and how does it works.

thanks for help شكراً لك :D
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Submit and Value ...

Post by markusn00b »

egturnkey wrote:markusn00b :D thanks very much

it helps me a lot and now i do understand how it should be and how does it works.

thanks for help شكراً لك :D
You are very welcome,
Mark.

نهارك سعيد
Post Reply