PHP - Trying To Process A Form W Multiple Checkboxes Then Redirect To A Thank You
Can someone please help? I am simply trying to email process a form with checkboxes and then redirect to a thank you page. It works fine as long as at least one checkbox is checked. It breaks if no checkboxes are checked using the implode function to list the "interests". I'm getting this error (and no redirect to my thank you page): Warning: implode() [function.implode]: Invalid arguments passed...
<?php if (isset($_REQUEST['submit'])) { $email = $_REQUEST['email']; $firstName = $_REQUEST['firstName']; $lastName = $_REQUEST['lastName']; $address = $_REQUEST['address']; $city = $_REQUEST['city']; $state = $_REQUEST['state']; $zipcode = $_REQUEST['zipcode']; $homePhone = $_REQUEST['homePhone']; $cellPhone = $_REQUEST['cellPhone']; $interest = $_REQUEST['interest']; $imploded_interest = implode(',',$interest); $comments = $_REQUEST['comments']; $to = 'myemailhere@yahoo.com'; $subject = 'Volunteer Signup'; $message = " <html> <head> <title>Volunteer Signup</title> </head> <body> <p>Hello,<br/>A visitor has submitted the following information from the volunteer page:</p> <p><b>$firstName $lastName</b><br/> $address<br/> $city, $state $zipcode<br/><br/> Home Phone: $homePhone<br/> Cell Phone: $cellPhone<br/> Email: <strong>$email</strong><br/><br/> I would like to help in the following ways:<br/> $imploded_interest </p><br/> <p>$firstName would also like share the following comments:<br/> <q><i>$comments</i></q> </p> </body> </html> "; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: Volunteer Signup <myemailhere@yahoo.com>' . "\r\n"; mail($to, $subject, $message, $headers); } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Volunteer</title> </head> <body> <form id="VolunteerForm" method="post" action="thankyou.php"> <table> <tr> <td style="width:150px;">Email Address:</td> <td><input name="email" type="text" id="email" /></td> <td style="width:320px;" class="padtr"><strong>Ways I can help:</strong></td> </tr> <tr> <td>First Name:</td> <td><input name="firstName" type="text" id="firstName" /></td> <td class="padtr"><input name="interest[]" value="yard-sign" type="checkbox"/> Put a yard sign in my yard</td> </tr> <tr> <td>Last Name:</td> <td><input name="lastName" type="text" id="lastName" /></td> <td class="padtr"><input name="interest[]" value="fundraiser-at-home" type="checkbox" /> Host a fundraiser at my home</td> </tr> <tr> <td>Address:</td> <td><input name="address" type="text" id="address" /></td> <td class="padtr"><input name="interest[]" value="phone-calls" type="checkbox" /> Make phone calls to friends and family</td> </tr> <tr> <td>City:</td> <td><input name="city" type="text" id="city" /></td> <td class="padtr"><input name="interest[]" value="mailings" type="checkbox" /> Help with mailings</td> </tr> <tr> <td>State:</td> <td><input name="state" type="text" id="state" /></td> <td class="padtr"><input name="interest[]" value="doors-literature" type="checkbox" /> Help knock on doors and distribute literature</td> </tr> <tr> <td>Zip Code:</td> <td><input name="zipcode" type="text" id="zipcode" /></td> <td class="padtr"><input name="interest[]" value="donate" type="checkbox" /> Make a donation</td> </tr> <tr> <td>Home Phone:</td> <td><input name="homePhone" type="text" id="homephone" /></td> <td class="padtr"><input name="interest[]" value="endorsement" type="checkbox" /> Use my name as an endorsement</td> </tr> <tr> <td>Cell Phone:</td> <td><input name="cellPhone" type="text" id="cellphone" /></td> <td class="padtr"><input name="interest[]" value="newsletter" type="checkbox" /> Sign up for our newsletter</td> </tr> <tr> <td>Comments:</td> <td><textarea name="comments" id="comments" rows="5" cols="17"></textarea></td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> <input type="submit" name="submit" id="submit" value="Submit Now" /> <input type="reset" name="reset" id="reset" value="Clear Form" /></td> </tr> </table> </form> </body> </html> Similar Tutorialshello all, im wondering if it is possible to have multiple check boxes that get created based on the number of rows in a table (one representing each row) Code: [Select] <input type='checkbox' name='approve[$tid]' value='ON'> and then have a submit button at the bottom of the page that will find all of the checkboxes (it could be 1, or 100) and submit it to my form handling page. thanks guys, I have looked on google for this and apparently noone is doing it. I have 4 checkboxes and I want to send mail indicating which boxes were checked. the only code I've found is PHP that captures the *status* of the boxes, such as "on" or "off". I want to capture the names of the actual checkbox elements. Here is the code I'm currently testing (which just prints out "on" or "off" to indicate which boxes are checked): if(isset($_POST['checkboxes'])) { foreach($_POST['checkboxes'] as $selected){ echo $selected . "</br>"; } } else { echo "No Desired Contact Time Specified."; } if I check all 4 boxes for instance, I get this: on on on on any way to get the names? thanks! Hi, my PHP code currently outputs the results from a users search by querying a backend postgresql database. As result/row is retuned to the user i would like to be able to detect whether or not they have checked a checkbox at the end of each rown in which case multiple rows can then be deleted from the database upon the user clicking a 'delete multiple records' button. I have no problem in being able to display the checkboxes on the webpage but i am a little unsure as to how to refernce them and detect which ones the user has checked. Given my database stores hostnames/IP addresses would it be best to name each checkbox to reflect the hostname or name the value it returns when checked to reflect the hostname. Given the above and that I also store the results of a users search in a $_SESSION['hosts'][][] array how can I then tie the two together? Thanks for reading. Ok so i want to grab an id from the checkbox then grab the option drop down associated with that check box and update a mysql row here is my code so far any help is awesome help taaaanks guys <?php mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db("db1") or die(mysql_error()); $query = "SELECT * FROM tickets ORDER BY id DESC"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { print "<input name='delete[]' value='{$row['id']}' type='checkbox'>"; mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db("db1") or die(mysql_error()); $query2 = "SELECT * FROM admin"; $result2 = mysql_query($query2) or die(mysql_error()); print "<form name='namestoupdate' method='post' action='update.php'>\n"; print '<select>'; while($row2 = mysql_fetch_array($result2)) { if ($row2['priv']==prov){print '<option value="'.$row2['user'].'" name="prov['.$i++.']">'.$row2['user'].'</option>';} } print '</select>'; print "<input type='submit' value='submit' />"; print "</form>"; } ?> Visual aid i am currently developing a voting system for a school project using dreamweaver.. on my vote page, i use checkboxes to select/vote a number of candidates. i want to automatically add/count the total tally and update my database upon submission of votes. since im new to php, all my codes are generated by dreamweaver..and dreamweaver doesn't have a function for handling multiple row update on database. can anyone please help with editing this code to make it work for my system? thanks in advance Code: [Select] <?php require_once('Connections/organizazone_db.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE tbl_candidates SET votecount=%s WHERE user_id=%s", GetSQLValueString(isset($_POST['vote[]']) ? "true" : "", "defined","1","0"), GetSQLValueString($_POST['user[]'], "text")); mysql_select_db($database_organizazone_db, $organizazone_db); $Result1 = mysql_query($updateSQL, $organizazone_db) or die(mysql_error()); } mysql_select_db($database_organizazone_db, $organizazone_db); $query_rs_candi = "SELECT * FROM tbl_candidates"; $rs_candi = mysql_query($query_rs_candi, $organizazone_db) or die(mysql_error()); $row_rs_candi = mysql_fetch_assoc($rs_candi); $totalRows_rs_candi = mysql_num_rows($rs_candi); $query_rs_candi = "SELECT * FROM tbl_candidates"; $rs_candi = mysql_query($query_rs_candi, $organizazone_db) or die(mysql_error()); $row_rs_candi = mysql_fetch_assoc($rs_candi); $totalRows_rs_candi = mysql_num_rows($rs_candi); ?> <form id="form1" name="form1" method="POST" action="<?php echo $editFormAction; ?>"> <table border="1"> <tr> <td> </td> <td>user_id</td> <td>votecount</td> </tr> <?php do { ?> <tr> <td><input name="vote[]" type="checkbox" id="vote[]" value="1" /> <label for="vote[]"></label></td> <td><label for="user[]"></label> <input name="user[]" type="text" id="user[]" value="<?php echo $row_rs_candi['user_id']; ?>" /></td> <td><?php echo $row_rs_candi['votecount']; ?></td> </tr> <?php } while ($row_rs_candi = mysql_fetch_assoc($rs_candi)); ?> </table> <br /> <br /> <input type="submit" name="submit" id="submit" value="Submit" /> <input type="hidden" name="MM_update" value="form1" /> </form> <?php mysql_free_result($rs_candi); ?> I have encountered a brick wall trying to use checkboxes. I am attempting to create a small form where I can record if a customer's item has been sent. The way I intend it to work is that the name and ID of the customer (stored in the 'customer' table) are retrieved through a query and displayed in two columns. In the third column is a checkbox beside the name and ID of each customer which, when ticked, sends a value to a second table called 'sentorders' for that particular person. As I am just trying to understand the basics of this for now, a list of all customers will be shown for the time being. The default value of the checkbox needs to be 'No' and if the checkbox is ticked the value should become 'Yes'. When a checkbox is ticked, the customer name, ID and current date are sent to the 'sentorders' table. Only if the box is ticked will the details be stored in the table. The problem I having is how do I set up the checkbox to work as described above. I have had a look at other questions online, but don't understand how it works. Any help would be appreciated. My current code is as follows. <?php $query = mysqli_query ($connect, "SELECT name, id FROM customer"); // Create Table echo '<table align="left"> <tr> <td align="left"><b>Name</b></td> <td align="left"><b>ID</b></td> <td align="left"><b>Order Sent</b></td> </tr>'; // Show Name/ID while ($row = mysqli_fetch_array($query)) { echo '<tr><form action="order_sent.php" method="post"><td align="left"> <td align="left">' . $row['name'] . '</a></td> <td align="left">' . $row['id'] . '</td> <input type="checkbox" name="order[];" value=''></tr>'; } echo '</table><p align="left"><input type="submit" name="enter" value="Update"/><input type="hidden" name="enter" value="TRUE" /></form>'; } ?> Hi All!! I am a little confused. I have a form where I want around 15 different checkboxes, all or some of these can be checked. When the form is sent I insert the fields into a database. I am wondering how I can have only the fields checked saved into the database, without having to have a row for each field. Thanks Chris hello. can (or rather how can) i put multiple checkboxes in to 1 db column? so, can i do this in 1 table: id - tick box id 1 - 1,2,3 2 - 4,5,6 3 - 7,8,9 and then relate that table to another table tick box id - name 1 - name1 2 - name2 3 - name3 etc.. if so, what format would i use in the db? varchar, enum or set (1,2,3 or '1','2','3') and how would i echo them out with the names from the second table? thanks I was wondering if this is possible. I have a list of criteria each with their own checkboxes, and I want to query a database when one or more of the checkboxes is submitted. So if 3 are checked, I want to query the database to find those 3 items. If one only is checked, I want to query the dataabse for one item. any ideas greatly appreciated thank you. this is basically a criteria based search Hey All, I tried seraching, but I'm not sure what exactly to search for. Here's what I need to do, and any push in the right direction would be great: I have a PHP form, with the Following: Text Box: Student ID Checkboxes for Activities What I need to do is somehow loop through and make a new row for each activity. Example, if I entered Student ID 105 and Activities are Basketball, Baseball, and Chess Team, I need three different rows in the database each listing the individual activity and the student ID. Any suggestions? I know how to do this if it was one entry (radio buttons) but want to be able to enter multiple rows at a time. Thanks! Hi all, iv been trying to compile a script that will allow users to select multiple checkboxs that will filter results from db..but to no avail. I have my data stored in mysql and have the queries saved seperatley. i.e. price = 0-500, 500-1000.etc. What im trying to achieve is to allow users to select a checkbox that will execute that particular query and also more importantly allow them to select 'multiple' checkboxes that will filter the results accordingly. I have never attempted to code this before although I am aware that it might involve arrays. If someone could give me a nudge in the right direction that would be great :-) With the following code
<?php ?> There is still an error output of syntax error on line 11, please help, what's wrong with my code Hey guys my code is like this Code: [Select] <?php if( $_POST["name"] || $_POST["age"] ) { echo "Welcome ". $_POST['name']. "<br />"; echo "You are ". $_POST['age']. " years old."; exit(); } ?> <html> <body> <form action="<?php $_PHP_SELF ?>" method="POST"> Name: <input type="text" name="name" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> The Inputs are taken from form.How do I make it display somewhere at the bottom of the form in the same page.The Output of this code comes up in a new page. I know how to pull data from sql table and limit down the results, what i wanted to do is pull data from a sql table 'finished' and list data that has paid='0' this is then limited to show the amount of rows set by variable 'maxPay' here is my list what im pulling atm; <h2>Payment </h2> <?php if($userType[user_type]==28){ $queryPay = mysql_query("SELECT * FROM finished WHERE paid='0'&&method!='FALSE'&&method!='credit';") or die(mysql_error()); $queryAdmin = mysql_query("SELECT maxPay FROM `admin`;") or die(mysql_error()); $row = mysql_num_rows($queryPay); //echo $row."row<br />"; $rowsArray = mysql_fetch_assoc($queryAdmin); $rows = $rowsArray[maxPay]; //echo $rows."rows<br />"; if($rows>$row){ $r=$row; } else{ $r=$rows; } $s=0; while($s<$r){ if($_POST[complete]==TRUE){ mysql_query("UPDATE `finished` SET `paid`='$_POST[paid]' WHERE `auctionID`='$_POST[aid]';"); $_POST[complete] = FALSE; } $s++; } $t=0; while($t<$r){ $queryuser = mysql_query("SELECT * FROM finished WHERE paid='0'&&method!='FALSE'&&method!='credit';") or die(mysql_error()); $user = mysql_result($queryuser, $t, "username"); //echo $user; $item = mysql_result($queryuser, $t, "itemName"); //echo $item; $value = mysql_result($queryuser, $t, "marketPrice"); //echo $value; $method = mysql_result($queryuser, $t, "method"); //echo $method; $id = mysql_result($queryuser, $t, "auctionID"); //echo $id; //echo $method; if($method=='isk'){ ?> <FORM method="post" action="pay.php"> <input type="hidden" name=complete value="TRUE" /> <input type="hidden" name=paid value="YES" /> <input type="hidden" name=username value="<? echo $user; ?>" /> <input type="hidden" name=aid value="<? echo $id; ?>" /> <input type="submit" value="Paid" /><? echo $user." won a ".$item." he selected to receive ".$value."ISK."; echo "<br />"; ?></FORM><? } elseif($method=='ship'){ ?> <FORM method="post" action="pay.php"> <input type="hidden" name=complete value="TRUE" /> <input type="hidden" name=paid value="YES" /> <input type="hidden" name=username value="<? echo $user; ?>" /> <input type="hidden" name=aid value="<? echo $id; ?>" /> <input type="submit" value="Paid" /><? echo $user." won a ".$item." he selected to receive the ship."; echo "<br />"; ?></FORM><? } else{ } $t++; } } else{ echo "You are not an Admin."; } ?> and pay.php: <?php header('Location: /admin.php'); include "connect.php"; echo $_POST[aid]; if($_POST[complete]==TRUE){ $tempID = (($_POST[aid])+1); mysql_query("UPDATE `finished` SET `paid`='$_POST[paid]' WHERE `auctionID`='$tempID';") or die(mysql_error()); $_POST[complete] = FALSE; } ?> at the moment i am listing all my data, and processing it using pay.php, each dataset has a "paid" button, i want to change this to using a checkbox at end of each data row, and a submit button at the bottom. this way i can select which rows to update and tick the checkbox, then click submit and those rows will then be updated the value '0' in db to a value of 'YES'. hope i explained myself clearly enough for some help. im a relative php noob still in training. I need some assistance with an error I get when trying to submit a form to my email address. the error is this: Warning: mail() [function.mail]: SMTP server response: 555 syntax error (#5.5.4) in E:\Contact\process.php on line 74 Sorry, unexpected error. Please try again later the form code is Code: [Select] <form id="form" action="process.php" method="post" name="ContactForm"> <label for="Name">Name</label> <input type="text" name="name" id="name" /> <label for="email">E-mail</label> <input type="text" name="email" id="email" /> <label for="website">Website</label> <input type="text" name="website" id="website" /> <label for="message">Message</label> <textarea class="resizable" name="comment"> </textarea> <input type="submit" name="submit" id="submit" value="Submit"> </form> and the process code [php] <?php //Retrieve form data. //GET - user submitted data using AJAX //POST - in case user does not support javascript, we'll use POST instead $name = ($_GET['name']) ? $_GET['name'] : $_POST['name']; $email = ($_GET['email']) ?$_GET['email'] : $_POST['email']; $website = ($_GET['website']) ?$_GET['website'] : $_POST['website']; $comment = ($_GET['comment']) ?$_GET['comment'] : $_POST['comment']; //flag to indicate which method it uses. If POST set it to 1 if ($_POST) $post=1; //Simple server side validation for POST data, of course, you should validate the email if (!$name) $errors[count($errors)] = 'Please enter your name.'; if (!$email) $errors[count($errors)] = 'Please enter your email.'; if (!$comment) $errors[count($errors)] = 'Please enter your comment.'; //if the errors array is empty, send the mail if (!$errors) { //recipient $to = 'My Name <email@gmail.com>'; //sender $from = $name . ' <' . $email . '>'; //subject and the html message $subject = 'Comment from ' . $name; $message = ' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head></head> <body> <table> <tr><td>Name</td><td>' . $name . '</td></tr> <tr><td>Email</td><td>' . $email . '</td></tr> <tr><td>Website</td><td>' . $website . '</td></tr> <tr><td>Comment</td><td>' . nl2br($comment) . '</td></tr> </table> </body> </html>'; //send the mail $result = sendmail($to, $subject, $message, $from); //if POST was used, display the message straight away if ($_POST) { if ($result) echo 'Thank you! I have received your message.'; else echo 'Sorry, unexpected error. Please try again later'; //else if GET was used, return the boolean value so that //ajax script can react accordingly //1 means success, 0 means failed } else { echo $result; } //if the errors array has values } else { //display the errors message for ($i=0; $i<count($errors); $i++) echo $errors[$i] . '<br/>'; echo '<a href="form.php">Back</a>'; exit; } //Simple mail function with HTML header function sendmail($to, $subject, $message, $from) { $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: ' . $from . "\r\n"; $result = mail($to,$subject,$message,$headers); if ($result) return 1; else return 0; } ?> [/php] I have this form I am trying to process, but it won't work? if($count==0){ Code: [Select] echo "That Bidder Number is NOT logged in, "; echo "would you like to set this bidder as active?"; echo " Enter 1 for NO or 2 for YES"; echo "<form action= \"process.php\" method= \"POST\">"; echo "<input type =\"text\" name= \"logUser\"/>"; echo "<input type= \"submit\" value = \"Submit\"/>"; $logUser= isset($_POST['logUser']) ? $_POST['logUser'] : ''; header("Location: process.php"); exit(); } All I want to do is process the users input and either input data into the database or simply redirect the user. Why the hell is this so complicated for?? I am processing the form on the same page it is displayed. Here's my procressing Code: [Select] if ($logUser= 1) { header("Location: inprogress.php"); exit(); } else if ($logUser= 2){ // Add $biddersId and redirect to anypage mysql_connect("$host", "$db_user", "$db_password")or die("cannot connect to server"); mysql_select_db("$db_name")or die("cannot select DB"); mysql_Query("INSERT INTO bidders (biddersId) VALUES ('$winningBidder')"); mysql_query("INSERT INTO transactions (itemDescription, itemPrice, bidderId, itemQty , totalPrice) VALUES('$itemDescription', '$itemPrice','$winningBidder', '$itemQty', '$totalPrice')") or die(mysql_error()); header("Location: inprogress.php"); exit(); } This is a strange one, as I have many forms on my various sites, and on this site, the file in question is used by several functions. Ultimately, I'm wanting it INSERT values from the form, which I'll eventually add more of. Form is process and is stent to rn_process.php, which is the code listed below. include(ABSPATH ."resources/con.php"); $grade = $_POST['grade']; $position = $_POST['position']; echo $grade.$position; $query = "INSERT INTO a_rankings_select (username,userID,grade,position) VALUES ('" .$username. "', '" .$userID. "', '" .$grade. "', '" .$position. "')";
It echoes the correct $grade and $position when I comment out the INCLUDE. So I know it's passing the correct values. However, when the INCLUDE is active, I get the following error: Quote
Warning: include(ABSPATHresources/con.php): failed to open stream: No such file or directory in /home2/csi/public_html/resources/rankings_navigation_process.php on line 2 resources/con.php is a file I link to many times, and it's work in those instances. It's certainly not executing the INSERT. Edited March 26, 2020 by Jim RThe error is "Error: Duplicate entry '' for key 'usr'" I don't have any fields with that name. here is the process code. <?php $con = mysql_connect("localhost","uname","pw") or die('Could not connect: ' . mysql_error()); mysql_select_db("db") or die(mysql_error()); $FirstName=mysql_real_escape_string($_POST['FirstName']); //This value has to be the same as in the HTML form file $LastName=mysql_real_escape_string($_POST['LastName']); //This value has to be the same as in the HTML form file $UserName=mysql_real_escape_string($_POST['UserName']); //This value has to be the same as in the HTML form file $Password= md5($_POST['Password']); //This value has to be the same as in the HTML form file $email=mysql_real_escape_string($_POST['email']); //This value has to be the same as in the HTML form file $Zip=mysql_real_escape_string($_POST['Zip']); //This value has to be the same as in the HTML form file $Birthday=mysql_real_escape_string($_POST['Birthday']); //This value has to be the same as in the HTML form file $Security=mysql_real_escape_string($_POST['Security']); //This value has to be the same as in the HTML form file /* * Specify the field names that are in the form. This is meant * for security so that someone can't send whatever they want * to the form. */ $allowedFields = array( 'FirstName', 'LastName', 'UserName', 'Password', 'email', 'Birthday', 'Zip', 'Security', ); // Specify the field names that you want to require... $requiredFields = array( 'FirstName', 'LastName', 'UserName', 'Password', 'email', 'Birthday', 'Zip', 'Security', ); $errors = array(); foreach($_POST AS $key => $value) { // first need to make sure this is an allowed field if(in_array($key, $allowedFields)) { $$key = $value; // is this a required field? if(in_array($key, $requiredFields) && $value == '') { $errors[] = "The field $key is required."; } } } // were there any errors? if(count($errors) > 0) { $errorString = '<p>There was an error processing the form.</p>'; $errorString .= '<ul>'; foreach($errors as $error) { $errorString .= "<li>$error</li>"; } $errorString .= '</ul>'; // display the previous form include 'index.php'; } else { $sql="INSERT INTO Profile (`FirstName`,`LastName`,`Username`,`Password`,`email`,`Zip`,`Birthday`,`Security`) VALUES ('$FirstName','$LastName','$UserName','$Password','$email','$Zip','$Birthday','$Security')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } //send email mail('email@gmail.com','A profile has been submitted!',$FirstName.' has submitted their profile',$body); // display the thank you page header("Location: thanks.html"); } Hi, I want to build into my html table that populates my database table to have a column for checkboxes with a delete button that takes the user to another page to confirm the deletion by outputting a message: Are you sure you want to delete ____, followed by a for loop to see how many checked records to get its ID in order to get its appropriate name. So I have a submit button with name attribute of "delete0" and the values of the input type of checkbox is $row['ID'], for some reason, I get the notice: "Notice: Undefined index: modifyArray in C:\display.php" and modifyArray is the name I give to the checkbox attribute (please see this in my display.php below) Here is my display.php Code: [Select] <table border="border"> <!--NB: checkbox form for multiple delete/update/insert--> <form method="post" action=""> <input type='submit' value='DELETE' name='delete0' /> <?php session_start(); require 'bellSessionDisconnect.inc'; require 'bellConnect.inc.php'; $result=mysql_query("SELECT ID, Image, Name, Manufacturer, Price, Description, SimSupport FROM bellProducts"); //phpinfo(); //NB: print table headings if(mysql_num_rows($result))//if there is at least one entry in bellProducts, make a table { //$counter+=1; print "<table border='border'>"; print "<tr> <th>ID</th> <th>Select entries to modifiy</th> <th>Image</th> <th>Name</th> <th>Manufacturer</th> <th>Price</th> <th>Description</th> <th>SimSupport</th> <th colspan='2' align='center'>Modify</th> </tr>"; //NB: now output each row of records while($row=mysql_fetch_assoc($result)) { //extract($row); "<tr align='center'> <td>$row[ID]</td> <td><input type='checkbox' name='modifyArray[]' value='$row[ID]' /></td> <td>"; if(!empty($row['Image'])) { $curImage=$row['Image']; } else if(empty($row['Image'])) { $curImage='fileUploadIcon.jpg'; //$title="please upload item image"; } print "<img src=$curImage width='70px' height='90px' /> </td> <td> $row[Name] </td> <td> $row[Manufacturer] </td> <td> $$row[Price]</td> <td align='left'>$row[Description]</td> <td>$row[SimSupport]</td> <td><a href='bellUploadForm.php?ID=$row[ID]'>UPLOAD IMAGE</a></td> <td><a href='bellUpdateForm.php?ID=$row[ID]'>UPDATE</a></td> </tr>"; //}//END INNER IF }//END WHILE }//END BIG IF ?> <?php if(array_key_exists('delete0', $_POST)) { $modifyArray=$_POST["modifyArray"]; if(!empty($modifyArray)) { header("Location: http://localhost/bellDeleteForm.php"); exit(); } } ?> </form> </table> I will worry about redirecting to bellDeleteForm.php to confirm the records the user wants to delete after I get this going, please help!!! thanks Hey all.. I have been messing around with some code with a form that has checkboxes on them, and the option of selecting more than one checkbox to submit to the database. However, I keep getting the error," Warning: Invalid argument supplied for foreach() in (mydirectory)". I have followed many tutorials and I don't see anything I am doing differently that they are, so I'm sure this is a simple fix, of something I am overlooking, or I am just horrible at this (new person). Here is the snippet of the HTML code for the checkboxes. Code: [Select] <label> <input type="checkbox" name="project_list[]" value="chat"/> Chat Project (age 18+ requirement)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="forums"/> Forums Project (age 18+ requirement)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="content"/> Content/Editorial Project (postcasts, blogging, etc.)</label> <br /> <label> <input type="checkbox" name="project_list[]" value="technology" /> Technology Project</label> <br /> <label> <input type="checkbox" name="project_list[]" value="marketing"/> Marketing, Promotions and Publicity</label> <br /> <label> <input type="checkbox" name="project_list[]" value="designartwork"/> Design and Artwork</label> Here is the PHP code that I am using to do this. Code: [Select] include 'db.php'; mysql_select_db('skylers_training'); if($_POST['submit']) { $project_lists = $_POST['project_list']; foreach($project_lists as $list); //This is the line the code is getting the error on. And the section of the INSERT MYSQL CODE for this part. Code: [Select] $reginsert = mysql_query("INSERT INTO ... // the rest of the code (that works fine) follows this. '$list' // This is the line that is supposed to send data from the checklists to the database. When I submit the form, in addition to the error, nothing is submitted to the database table for the list (everything else works fine). Any insight into this, would be appreciated. Thanks! |