Jump to content

can anybody help me!


zafira

Recommended Posts

We won't do your homework for you.

 

I you want help, show us your current code and tell us what exactly your problem is. And please choose proper thread titles. Nonsense like “I need help” doesn't tell us anything, because everybody who creates a thread obviously needs help.

Link to comment
https://forums.phpfreaks.com/topic/298654-can-anybody-help-me/#findComment-1523527
Share on other sites

<?php

 

 

// Read the selected language.

$language = ($_REQUEST['language']);

 

// make the language array.

$language=array(1=>'Malay','English','Chiness','India');

 

// make the language pull-down menu.

echo'<select name="language">';

foreach($language as $key =>$value) {

echo"<option value=\"$key\">$value</option>\n";

}

echo '</select>';

// Validate the gender.

if (isset($_REQUEST['language'])) {

$language = ($_REQUEST['language']);

 

if ($language == 'Malay') {

$message = '<P><b>Good day, Sir!</b></p>';

 

} else ($language == 'English') {

$message = '<P><b>Good day, Madam!</b></p>';

 

} else ($language == 'Chiness') {

$message = '<P><b>Good day, Madam!</b></p>';

 

} elseif ($language == 'India') {

$message = '<P><b>Good day, Madam!</b></p>';

 

} else { // Unacceptable value.

$message = NULL;

echo '<p><font color="red">You forgot to enter your name!</font></p>';

}

 

}else { //$_REQUEST['gender'] is not set.

$language = NULL;

echo '<p><font color="red">You forgot to enter your name!</font></p>';

}

 

?>

<form action="choose.php" method="post">

 

<br/>

<input type="submit" value="GO!"/>

 

 

</form>

 

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/298654-can-anybody-help-me/#findComment-1523528
Share on other sites

It's a lot easier to use an array for the messages

 

form

<select name='language'>
    <option value='1'>English</option>
    <option value='2'>French</option>
    <option value='3'>German</option>
    <option value='4'>Klingon</option>
</select>

processing

<?php
$translations = array (
                    1 => 'Welcome',
                    2 => 'Bienvenue',
                    3 => 'Herzlich Willkommen',
                    4 => 'yI\'el'
                );
echo $translations[$_GET['language']];
?>
Link to comment
https://forums.phpfreaks.com/topic/298654-can-anybody-help-me/#findComment-1523531
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.