Jump to content

Htmlradio buttons


shirvo

Recommended Posts

Heres an easy emaple of how the array works ok.


<?php

$a[]="Save my name";
$a[]="Save my username";
$a[]="Save my age";
$a[]="Save my address";

$save_array=array("my name","my username","my age","my address");

foreach ($save_array as $result1){ 

foreach($a as $result2){

$result=$result1.$result2;

echo "you have selected $result to be saved <br>";

}

}

?>

Link to comment
Share on other sites

that didn't help. this is what i have

 

<html><head>

</head><body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<table>

<tr><td>Username:</td><td><input type="text" name="user" maxlength="40" value="<? echo $_COOKIE['username']; ?>"></td></tr>

<tr><td>Password:</td><td><input type="password" name="pass" maxlength="40" value="<? echo $_COOKIE['password']; ?>"></td></tr>

<tr><td colspan="2"><input type="radio" name="V1[1]">Save my username and password</td></tr>

<tr><td colspan="2"><input type="radio" name="V1[2]">Save my username</td></tr>

<tr><td colspan="2"><input type="radio" name="V1[3]">Ask for my username and password</td></tr>

<tr><td colspan="2"><input type="submit" value="Login" name="login"></td></tr>

</table>

</form>

</body></html>

 

so what am i meant to put in the name for each radio button

Link to comment
Share on other sites

<html><head> 
</head><body> 
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr><td>Username:</td><td><input type="text" name="user" maxlength="40" value="<? echo $_COOKIE['username']; ?>"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass" maxlength="40" value="<? echo $_COOKIE['password']; ?>"></td></tr>
<tr><td colspan="2"><input type="radio" name="V1[]">Save my username and password</td></tr>
<tr><td colspan="2"><input type="radio" name="V1[]">Save my username</td></tr>
<tr><td colspan="2"><input type="radio" name="V1[]">Ask for my username and password</td></tr>
<tr><td colspan="2"><input type="submit" value="Login" name="login"></td></tr>
</table>
</form>
</body></html>

 

now look at my example agin ok.

Link to comment
Share on other sites

<html><head>

</head><body>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

<table>

<tr><td>Username:</td><td><input type="text" name="user" maxlength="40" value="<? echo $_COOKIE['username']; ?>"></td></tr>

<tr><td>Password:</td><td><input type="password" name="pass" maxlength="40" value="<? echo $_COOKIE['password']; ?>"></td></tr>

<tr><td colspan="2"><input type="radio" name="V1[]" value="yes">NAME</td></tr>

<tr><td colspan="2"><input type="radio" name="V1[]" value="yes">PASSWORD</td></tr>

<tr><td colspan="2"><input type="submit" value="Login" name="login"></td></tr>

</table>

</form>

</body></html>

 

This might work if the user selected

name AND PASSWORD then update the database or otherwise dont.

 

<?php

foreach($V1 as $x){

if(($x=="yes"){

//update database

}else{

echo " You must select username and password to register"; 

}
}
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.