PHP - Need To Count Yes Response To Radio Button
Hello I'm working on a program that collects the Yes and No responses via a radio button. If I receive 2 or more answers of Yes I will need to send out and email otherwise nothing will happen. Can someone please tell me how can I get my Yes to work by collect the number of Yes responses?? Thank you in advance. Similar TutorialsYou would think the answer would be all over the Internet and easy to find, but it’s not. I have searched many times, and in all the multitude of search results I have still never found an adequate usable answer. The MOST you ever find is someone saying how easy it is with PHP, but they don’t tell you how, even when the person they are answering asks them (odd). You can be that one in a billion person who finally answers it for real and helps someone out. I have a simple HTML form with data fields first_name, last_name, email, phone, country, a few hidden inputs, and a single submit button, like so: (Please note: the method is GET, not Post.) <form action="https://MyDomainOnMyServer.com/MyPHPScript.php”> <input type="text" name="first_name" value="" /> <input type="text" name="last_name" value="" /> <input type="text" name="email" value="" /> <input type="text" name="phone" value="" /> <input type="hidden" name="type" value="type123"> <input type="hidden" name="project" value="new123"> <select required name="country"> <option value="">Choose your country</option> <option value="US">United States</option> <option value="CA">Canada</option> <option value="GB">United Kingdom</option> <option value="Many More">Many More Countries</option> </select> <input type="submit" value="Submit Form" /> </form> NOTE: Originally, the form action would have been: action="https://TheirExampleDomainOnTheirRemoteServer.com/TheirRemotePHPScript.php" name="form1234" Upon clicking the single submit button only, what I need to have happen is this: 1. Send me an email to whatever@whatever.tld containing all the form submission data 2. Place the form submission data into a MySQL database having the corresponding data fields 3. Send the form submission contents including the hidden input values to "https://TheirExampleDomainOnTheirRemoteServer.com/TheirRemotePHPScript.php" name="form1234" AS IF that had remained set as the original form action to begin with So basically what I’m trying to obtain is the cleanest possible PHP script that will do those three things, which is essentially what others have asked for over the years in search results I have found, but no one has ever provided it in a clear instance that works. If I can just see such a script, I should be able to see how it works and then do what I need. Thanks. Reply A HTTP request is made to the server, Slim creates a Request and Response object, content in the Request is sent to another server using cURL via Guzzle, Guzzle returns its own Response, and content from Guzzle's response must be returned by the original Slim response. Would you recommend white-listing or black-listing response headers, and which specific headers? Similarly, would you recommend white-listing or black-listing the request headers sent via cURL, and which specific headers? Thanks <?php use Psr\Http\Message\ResponseInterface as Response; use GuzzleHttp\Psr7\Response as CurlResponse; class ApiResponder { public function delete(Response $httpResponse, CurlResponse $curlResponse) { return $this->proxy($httpResponse, $curlResponse); } //other public methods... private function proxy(Response $httpResponse, CurlResponse $curlResponse) { foreach($this->getResponseHeaders($curlResponse) as $name=>$value) { $httpResponse=$httpResponse->withHeader($name, $value); } return $httpResponse->withBody($curlResponse->getBody())->withStatus($curlResponse->getStatusCode()); } private function getResponseHeaders(Response $httpResponse):array { //Blacklist headers which should be returned to original client. TBD whether I should whitelist headers instead. $blacklist=['Date'=>null, 'Server'=>null, 'X-Powered-By'=>null, 'Access-Control-Allow-Origin'=>null, 'Access-Control-Allow-Methods'=>null, 'Access-Control-Allow-Headers'=>null, 'Set-Cookie'=>null]; return array_diff_key($curlResponse->getHeaders(), $blacklist); } /** * This method doesn't really exist in this class, but is just included to show which headers I am forwarding in the cURL request. */ private function getRequestHeaders($clientRequest):array { $whitelist=['connection'=>null,'accept'=>null,'accept-encoding'=>null,'accept-language'=>null,'content-type'=>null,'content-length'=>null]; return array_intersect_key($clientRequest->getHeaders(), $whitelist); } }
Probably i`m the newbiest guy around here, so i have some questions for you guys. I have the following code: Quote <?php $urna=array(0,1,2,3,4,5,6,7,8,9,"a","b","c","d","e","f"); $culoare="#"; for ($i=1; $i<=6; $i++) $culoare.=$urna[rand(0,15)]; ?> <body bgcolor="<?php echo $culoare;?>"> <form method=post> <input type="submit" name="submit" value="Schimba culoarea" /> </form> Now, i need to "count" how many times the "submit" button has been hit, and for every 4 hits the color will be changed. So, anyone have any clue how could i do that? Hello, I had 3 radio buttons with the same name, well, I had created 3 text box that are next to those 3 radio buttons. When I click save to the form, I need to know which radio button had been pressed, so that I can detect & retrieve its value. Any help? Thanks I am trying to have the text alongside the radio button trigger the radio button (cannot use < a href ) e.g. () Trigger with this text The closest I have found is <label for="r1"><input type="radio" name="group1" id="r1" value="1" /> button one</label> But it does not seem to work? Any help greatly appreciated I have a function to display some images and allow a user to select a choice via a radio button.The value is then passed to another function. I have 2 problems My selection is not being passed back and I cant assign the value to a query sring in a link to another page. On the form do i need to add checked? Any help appreciated. Code: [Select] function cover() { echo'<h2>Please upload your book cover or choose one from the selection</h2> <p>All book ideas require a cover. Your choice can be changed at a later date.</p>'; //process selection of cover if (isset($_POST['submit'])) { $coverID=$_POST['cover']; echo $coverID; ?>   <ul><li class="demo-menu-link"><a href="?page=submenu7&coverID=$coverID">Finnished Cover</a></li></ul><?php exit(); } else{ echo "not Submitted"; } global $wpdb; $query = "select * from wp_cover"; $result = mysql_query($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); echo mysql_error(); if (!$result){ return false; } echo'<div class="wrap"><p>choose from one of the covers below</p></div>'; ?><form action="<?php $_SERVER['PHP_SELF'] ?>" method="POST" id="cover" enctype="multipart/form-data"> <table><tr><?php /* display picture and radio button */ while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $coverID=$row['coverID']; echo"<img src=\"/wordpress_3/wp-content/plugins/Authors2/jackets/{$row['pix']}\" />"; echo"<td>"; echo $coverID; echo "<Input type = 'Radio' Name ='cover' value= '$coverID'/>"; ?> </tr></table> <input type=submit value=submit> </form><?php } } What am I doing wrong with this selected radio button? <form action="Process/privacy.php" method="post" enctype="multipart/form-data" id="privacy"> <div id="privacy_vis">Your profile is visible to:</div> <div id="privacy_select"> <label> <input name="RadioGroup1" type="radio" id="RadioGroup1_0" value="1" <?if($visible=="1")echo 'checked="checked"';?> /> Everyone</label> <label> <input name="RadioGroup1" type="radio" id="RadioGroup1_1" value="0"/> Members Only</label> </div> <br /> <div id="privacy_vis">Your Password to view your private pictures is:</div> <div> <input name="pictures_pw" type="text" id="pictures_pw" value="<? echo "$xxx_pw" ?>" size="50" maxlength="20" /> </div> <br /> <div> <input name="submit" type="submit" class="button" id="submit" value="Save Changes" /> </div> </form> </div> I have a group of 4 radio buttons. my mysql database knows which one the user selected previously when they stored some information. I now wish to display the same buttons but have radio button checked that the user chose before. I know this can be done but having one of those mind melt moments where I cannot think of the solution so I have 4 buttons that look like this Code: [Select] <input type="radio" name="clarity" id="clarity" value="Opaque"> Opaque<br> <input type="radio" name="clarity" id="clarity" value="Deep"> Deep<br> <input type="radio" name="clarity" id="clarity" value="Mid"> Mid<br> <input type="radio" name="clarity" id="clarity" value="Pale"> Pale<br></td> I just need to attached a checked field to the correct item i would like to display the value of the selected radio button on the same page... what i want is just reload the page and if there is a radio button selected displays it but i cant display it <?PHP if (isset($_GET["submit"])) { echo $_GET["myradio"]; } ?> <html> <head> </head> <body> <form action="<?PHP $_SERVER["PHP_SELF"]; ?>" method="get"> One <input type="radio" name="myradio" value="one"> Two <input type="radio" name="myradio" value="two"> <a href="<?PHP $_SERVER["PHP_SELF"]; ?>" name="submit">test </a> </form> </body> </html> please help guys...thanks I am trying to make a set of radio buttons that when you make a selection, it displays a sorted database from MYSQL. I have the MYSQL part figured out but I cannot figure out how to properly display it. I have the following code and I made a select screen just to test: index.html <html> <body> <form action="select.php" method="post"> <input type="radio" name="table" value="table1"> Table 1 <br> <br> <input type="radio" name="table" value="table2">Table 2 <br> <br> <input type="radio" name="table" value="table3">Table 3 <br> <br> <input type="radio" name="table" value="table4">Table 4 <br> <br> <input type="radio" name="table" value="table5">Table 5 <br> <br> <input type="Submit" Name = "submit" value="Submit"> <input type="Reset" value="Reset"> </form> </body></html> select.php <?PHP $selected_radio = $_POST["table"]; if ($selected_radio = = 'table1) { echo "Table 1 Here."; } else if ($selected_radio = = 'table2') { echo "Table 2 Here."; } else if ($selected_radio = = 'table3') { echo "Table 3 Here."; } else if ($selected_radio = = 'table4') { echo "Table 4 Here."; } else if ($selected_radio = = 'table5') { echo "Table 5 Here."; } ?> These are two separate files. When I go to run the code, no matter what I pick, the next page is always blank. Again, the select.php is just suppose to be a check, the real code will display the table instead of echoing a message. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=317717.0 Good Day, I juz like to know if there any other alternative way for the code below, coz i can't update my form when i use this method for radio the button. It's not passing the value. Code: [Select] Edit.php <tr> <td height="36" align="center" valign="middle" bgcolor="#990000"><div align="left" class="style4">Destroy :</div></td> <td align="center" valign="middle" bgcolor="#990000"><div align="left"> <label> <input type=radio name=destroyR value="Yes" <?php echo ($rows['destroy']=='Yes') ?'checked="checked"':''; ?> />Yes</label> <label> <input type=radio name=destroyR value="No" <?php echo ($rows['destroy']=='No') ?'checked="checked"':''; ?> />No</span></label> </div></td> </tr> how do you make it so that a radio button is either checked or unchecked based on database? Hi, I have 2 radio button's within a table and need to pass this array. All other rows within my table can be sent as array's and captured using $_POST['field_name'][$ROW 1 value etc]. However for radio buttons this doesn't work. As an example, a standard textbox I can send an array using the following: echo "<td width='33%'><input type='Textbox' width='100%' id='test' name='test[]' value='" .$row['test']. "'></td>"; I can then capture it using: $test = $_POST['test'][$iLine]; This works, no problem, however for radio buttons, I can't use a static array name, as presumably it dumps all rows into the array, if I do this, only the last row has a checked button, hence I need to use the following (where $checked includes the logic to decide whether the button should be checked or not, this works correctly): echo "<input type='radio' name='".$row['venue_id']."[]' value='1'".$checked."/>P1" echo "<input type='radio' name='".$row['venue_id']."[]' value='0'".$checked2." />P2"; I tried using the following: var_dump($_POST[$row]['game_id'][$iLine]); But this just returns a null value. Any ideas? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=346803.0 Hello, I have a simple PHP form that sends the results as a message to my email address. The form is composed only of text areas and text fields. All works well until I try to introduce radio buttons. When I get the message the result is blank. This is the form: <form id="contact-form" name="contact-form" method="post" action="submit.php"> <table width="100%" border="0" cellspacing="0" cellpadding="5"> <tr> <td><label for="name">Your Name:</label></td> <td><input type="text" class="validate[required,custom[onlyLetter]]" name="name" id="name" value="<?=$_SESSION['post']['name']?>" /></td> <td id="errOffset"> </td> </tr> <tr> <td><label for="email">Your Email Address:</label></td> <td><input type="text" class="validate[required,custom[email]]" name="email" id="email" value="<?=$_SESSION['post']['email']?>" /></td> <td> </td> </tr> <tr> <td valign="top"><label for="message">How can we help you</label></td> <td><textarea name="message" id="message" cols="35" rows="3"><?=$_SESSION['post']['message']?></textarea></td> <td valign="top"> </td> </tr> <tr> <td><label for="contact">Preferred method of contact:</label></td> <td> <label class="second" for="contact">By Email:</label><input name="<?=$_SESSION['post']['contact']?>" id="contact-email" type="radio" value="Email" checked /> <label class="second" for="contact">By Phone:</label><input name="<?=$_SESSION['post']['contact']?>" id="contact-phone" type="radio" value="Phone" /> </td> <td id="errOffset"> </td> </tr> <tr> <td><label for="captcha">Security Question: <?=$_SESSION['n1']?> + <?=$_SESSION['n2']?> =</label></td> <td><input type="text" class="validate[required,custom[onlyNumber]]" name="captcha" id="captcha" /></td> <td valign="top"> </td> </tr> <tr> <td valign="top"> </td> <td colspan="2"><input type="submit" name="button" id="button" value="Submit" /> <input type="reset" name="button2" id="button2" value="Reset" /> <?=$str?> <img id="loading" src="img/ajax-load.gif" width="16" height="16" alt="loading" /></td> </tr> </table> </form> <?=$success?> And this is the submit.php file it refers to: <?php /* config start */ $emailAddress = 'email@gmail.com'; /* config end */ require "phpmailer/class.phpmailer.php"; session_name("fancyform"); session_start(); foreach($_POST as $k=>$v) { if(ini_get('magic_quotes_gpc')) $_POST[$k]=stripslashes($_POST[$k]); $_POST[$k]=htmlspecialchars(strip_tags($_POST[$k])); } $err = array(); if(!checkLen('name')) $err[]='The name field is too short or empty!'; if(!checkLen('email')) $err[]='The email field is too short or empty!'; else if(!checkEmail($_POST['email'])) $err[]='Your email is not valid!'; if((int)$_POST['captcha'] != $_SESSION['expect']) $err[]='The captcha code is wrong!'; if(count($err)) { if($_POST['ajax']) { echo '-1'; } else if($_SERVER['HTTP_REFERER']) { $_SESSION['errStr'] = implode('<br />',$err); $_SESSION['post']=$_POST; header('Location: '.$_SERVER['HTTP_REFERER']); } exit; } $msg= 'Name: '.$_POST['name'].'<br /> Email: '.$_POST['email'].'<br /> Message: '.$_POST['message'].'<br /> Contact by: '.$_POST['contact'].' '; $mail = new PHPMailer(); $mail->IsMail(); $mail->AddReplyTo($_POST['email'], $_POST['name']); $mail->AddAddress($emailAddress); $mail->SetFrom($_POST['email'], $_POST['name']); $mail->Subject = "Contact Form"; $mail->MsgHTML($msg); $mail->Send(); unset($_SESSION['post']); if($_POST['ajax']) { echo '1'; } else { $_SESSION['sent']=1; if($_SERVER['HTTP_REFERER']) header('Location: '.$_SERVER['HTTP_REFERER']); exit; } function checkLen($str,$len=2) { return isset($_POST[$str]) && strlen(strip_tags($_POST[$str])) > $len; } function checkEmail($str) { return preg_match("/^[\.A-z0-9_\-\+]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $str); } ?> These are the 2 files I've been updating. I'm definitely not good at PHP so any help cracking this problem would be welcome. Thank you. <?php
require_once('upper.php'); require_once('LoginStatement.php'); require_once('database.php'); echo $error_msg=''; require_once('database.php'); $LoginId=$_COOKIE['LoginIdCookie']; $query="select * from registration where LoginId='$LoginId'"; $result=mysqli_query($dbc,$query); $row=mysqli_fetch_array($result); if(isset($_POST['submit'])) { $LoginId=mysqli_real_escape_string($dbc,trim($_POST['LoginId'])); $Name=mysqli_real_escape_string($dbc,trim($_POST['Name'])); $Age=mysqli_real_escape_string($dbc,trim($_POST['Age'])); $BloodGroup=mysqli_real_escape_string($dbc,trim($_POST['BloodGroup'])); if(!isset($_POST['Sex'])) { echo 'Please enter Sex<br>'; } else{ $Sex= mysqli_real_escape_string($dbc,trim($_POST['Sex'])); } $Qualification=mysqli_real_escape_string($dbc,trim($_POST['Qualification'])); $ContactNumber=mysqli_real_escape_string($dbc,trim($_POST['ContactNumber'])); $Email=mysqli_real_escape_string($dbc,trim($_POST['Email'])); $Address=mysqli_real_escape_string($dbc,trim($_POST['Address'])); $AboutYourself=mysqli_real_escape_string($dbc,trim($_POST['AboutYourself'])); //$countCheck=count($_POST['checkbox']); //echo $countCheck; //$checkbox=$_POST['checkbox']; //$countCheck=count($checkbox); if(empty($LoginId)){echo 'Please enter Login Id';} elseif(empty($Name)){echo 'Please enter Name';} elseif(empty($Age)){echo 'Please enter Age';} elseif(!isset($_POST['Sex'])){} elseif(empty($Qualification)){echo 'Please enter Qualification';} elseif(empty($ContactNumber)){echo 'Please enter Contact Number';} elseif(empty($Email)){echo 'Please enter Email';} elseif(empty($Address)){echo 'Please enter Address';} elseif(empty($AboutYourself)){echo 'Please enter About Yourself';} else { if(mysqli_num_rows($result)==0) { $checkbox=$_POST['checkbox']; $countCheck=count($_POST['checkbox']); $reg_id=' '; for($i=0;$i<$countCheck;$i++) { $reg_id=$reg_id.$checkbox[$i].','; } $query="UPDATE registration SET (LoginId,Name,Age,BloodGroup,Sex,Qualification,ContactNumber,Email,Address,AboutYourself,Activity)values ('$LoginId',SHA('$Password1'),'$Name','$Age','$BloodGroup','$Sex','$Qualification','$ContactNumber','$Email','$Address','$AboutYourself',',$reg_id')"; $result=mysqli_query($dbc,$query) or die("Not Connect"); echo ' Dear '.$Name.'.<br>Your request has been mailed to admin.<br>Your account is waiting for approval<br>'; $from= 'Elite Brigade'; $to='ankitp@rsquareonline.com'; $subject='New User Registration'; $message="Dear admin,\n\nA new user request for registration. Please check it out.\n\nRegards\nMicro"; mail($to,$subject,$message,'From:'.$from); //header('Location: index.php'); // header('Location: Registration.php'); } else { echo 'Dear '.$Name. ', <br> An account already exist with login-id<b> '.$LoginId.'</b> <br>Please try another login-id'; }} } ?> <html> <head> <script src="jquery-latest.js"></script> <script type="text/javascript" src="jquery-validate.js"></script> <style type="text/css"> * { font-family: Verdana; } label.error { color: white; padding-left: .5em; } p { clear: both; } .submit { margin-left: 12em; } em { font-weight: bold; padding-right: 1em; vertical-align: top; } </style> <script> $(document).ready(function(){ $("#commentForm").validate(); }); </script> </head> <body> <?php echo $error_msg; ?> <form action='<?php echo $_SERVER['PHP_SELF'];?>' id="commentForm" method='post'> <div class="registration_and_activity"> <table border="0" width="380"> <tr><td colspan="2"> <h3>Update Personal Details</h3></td></tr> <tr><td width="120"> <em>*</em>Enter Login id</td><td width="150"><input type='text' name='LoginId' minlength='4' value='<?php echo $row['LoginId']; ?>' /></td></tr> <tr><td width="120"> <em>*</em>Enter Name</td> <td><input type='text' name='Name' value='<?php echo $row['Name'];?>' /></td></tr> <tr><td> <em>*</em>Enter Age</td><HEAD> <SCRIPT language=Javascript> function isNumberKey(evt) { var charCode = (evt.which) ? evt.which : event.keyCode if (charCode > 31 && (charCode < 48 || charCode > 57)) return false; return true; } </SCRIPT> </HEAD> <td><INPUT onkeypress='return isNumberKey(event)' type='text' name='Age' value='<?php echo $row['Age'];?>'/></td></tr> <tr><td> <em>*</em>Enter Blood</td><td><input type='text' name='BloodGroup' value='<?php echo $row['BloodGroup'];?>' /></td></tr> [B]<tr><td> <em>*</em>Enter Sex</td><td><input type='radio' name='Sex' style='width:16px; border:0;' value='Male' checked='<?php if($row['Sex']='Male') echo 'checked';?>'/>Male <input type='radio' name='Sex' checked='<?php if($row['Sex']='Female') echo 'checked';?>' style='width:16px; border:0;' 'value='Female' />Female</td></tr>[/B] <tr><td> <em>*</em>Enter Qualification</td><td><input type='text' name='Qualification' value='<?php echo $row['Qualification'];?>' /></td></tr> <tr><td> <em>*</em>Contact Number </td><td><input onkeypress='return isNumberKey(event)'type='text' name='ContactNumber' value='<?php echo $row['ContactNumber'];?>' /></td></tr> <tr><td> <em>*</em>Enter Email</td><td><input type='text' name='Email'class="email" value='<?php echo $row['Email'];?>' /></td></tr> <tr><td> <em>*</em>Enter Address</td><td><input type='text' name='Address' value='<?php echo $row['Address'];?>' /></td></tr> <tr ><td > <em>*</em>About Yourself </td></tr> <tr><td colspan="2"><textarea rows='10' cols='40' name='AboutYourself' /><?php echo $row['AboutYourself'];?></textarea></td></tr> <tr><td> <?php echo "<tr><td colspan='2' align='center'><input type='submit' value='Update' name='submit' style='background:url(./images/button_img2.png) no-repeat 10px 0px; width:100px; padding:3px 0 10px 0; color:#FEFBC4; border:0;'/></td></tr><br>"; echo " </td></tr></table> </div> </form> </body> </html>"; require_once('lower.php'); ?> Hi friends.......... In above code I want that In database if Sex=Male then Male radio button will be checked automatically and if Sex =Female then Female radio button will be checked. But it not works ........... please help me........... thanks in advance.......... I am having some difficulty with accessing radio button values with PHP code. Please see the attached file
Attached Files
x.txt 530bytes
11 downloads <?php $SQL = "SELECT stu_satisfaction_tblquestions.question_id, stu_satisfaction_tblquestions.question, answer_type.* FROM stu_satisfaction_tblquestions LEFT JOIN answer_type ON stu_satisfaction_tblquestions.answers_id=answer_type.answers_id WHERE stu_satisfaction_tblquestions.answers_id BETWEEN '1' AND '2' "; $result = mysql_query($SQL); while ($data = mysql_fetch_array($result)) { echo $data['question'].'<br/>'; echo '<input type="radio" name="answers['.$data['question_id'].']" id="'.$data['question_id'].'_'.$data['answer1'].'" value="1" /><label for="'.$data['question_id'].'_'.$data['answer1'].'">'.$data['answer1'].'</label><br/>'; echo '<input type="radio" name="answers['.$data['question_id'].']" id="'.$data['question_id'].'_'.$data['answer2'].'" value="2" /><label for="'.$data['question_id'].'_'.$data['answer2'].'">'.$data['answer2'].'</label><br/>'; echo '<input type="radio" name="answers['.$data['question_id'].']" id="'.$data['question_id'].'_'.$data['answer3'].'" value="3" /><label for="'.$data['question_id'].'_'.$data['answer3'].'">'.$data['answer3'].'</label><br/>'; echo '<input type="radio" name="answers['.$data['question_id'].']" id="'.$data['question_id'].'_'.$data['answer4'].'" value="4" /><label for="'.$data['question_id'].'_'.$data['answer4'].'">'.$data['answer4'].'</label><br/>'; echo '<input type="radio" name="answers['.$data['question_id'].']" id="'.$data['question_id'].'_'.$data['answer5'].'" value="5" /><label for="'.$data['question_id'].'_'.$data['answer5'].'">'.$data['answer5'].'</label><br/>'; } ?> this is my form, how should i validate the radio buttons of it? i have an rsvp page where the table is populated by guests according to event selected in the drop down list. the rsvp table has 2 columns: guest names and status. status(radio button) is divided into 3: unconfirmed(default status), attending and not attending. user has to choose either one. but i am having trouble saving the status. tia for any help!
this is the saving code:
<?php if(isset($_SESSION['sess_user_id'])) { if(isset($_POST['save-rsvp'])) { require "connection.php"; $name = $_POST['name']; $radio = $_POST['rsvp']; $session = $_SESSION['sess_user_id']; $rsvp = $dbh->prepare("UPDATE guest SET status = ? WHERE guser_id = ? AND guest_name = ?"); $rad = implode("','", $radio); for($i = 0; $i < count($_POST['name']); $i++) { if(trim($_POST['name'][$i]) !== '')// validate this form { $rsvp->bindParam(1, $rad, PDO::PARAM_INT); $rsvp->bindParam(2, $session, PDO::PARAM_INT); $rsvp->bindParam(3, $name[$i], PDO::PARAM_STR); $rsvp->execute(); } } } } ?>which when save doesn't save according to status selected. for example 5 names: noreen, pete, marzuki, nora, mishal noreen unconfirmed pete attending marzuki attending nora attending mishal not attending micah not attending when saved, all is saved as unconfirmed. noreen not attending pete attending marzuki not attending nora attending mishal not attending micah attending when saved, all is saved as not attending. noreen attending pete not attending marzuki attending nora not attending mishal attending micah not attending when saved, all is saved as attending. it seems to save according to first choice. |