PHP - Question With Checkboxes And Sending Links
I cant seem to grasp how to accomplish this...
I have 10 check boxes in a form on submit I need to be able to see which boxes where checked and depending on which ones were checked display a static link for each. so if i select boxes 1, 5, 8 i will get back www.link.com/1.php www.link.com/5.php www.link.com/8.php thanks Similar TutorialsHey everyone. [= I don't have much time to read through all of the forums, because I'm on a time crunch and I'll be putting this certain project behind a couple others while I wait for some answers. This project is confusing me a bit, because I haven't worked much with arrays and the good ol' checkbox, so I need some help getting this to work. This project requires me to set-up a checkbox next to each order that was pulled off a database. You are allowed to select as many checkboxes as you'd like, and then click on the "process receipts" for all of the orders that were selected. I need to be able to have the form send me straight to a new page that pulls a loop of receipts one after another. I have the receipts built, and I can access a receipt one at a time based off the ID of a certain order, and I can easily build a loop that presents the receipts. I'm just having a problem pulling the information off the database based from the checkbox array. If you can give me some ideas on where to start with this, I'd greatly appreciate it. Note: Example is inside a hidden administrative page. Can't really give you something to play with, sorry! QQ Thanks! Alex D.A. Designing Hey everyone, I am trying to set up a thing where i will have a list of states in a drop down list. After a state is select i would like a section of check boxes to appear with cities that a person can choose from. Can anyone help me out with this i have looked on the internet and been trying to code this my self but with progress. I can work with php or java script all i need is some help on getting started and maybe an example. Thanks E 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. Im making a map atm which will have tokens"not sure what you call them" in the link like map.php?id=token Well I dont want a 3rd party coming along in the future and making their own map using my y and x cords. So I was thinking maybe the best way around this is to use a encryption in the link? so encrypting the x and y cords in the link. Anyone have any ideas on this. Also I was wondering is it impossible for php to know when somone clicks a link? I was googling around and it doesnt seem like you cant simply use a $_POST for a link From our website we are connecting to GMAIL to send our emails through SMTP. For some reason it is not sending the emails to the CC or BCC email address event though GMAIL shows it was included in the email. Am I missing something in the below code? Code: [Select] $currentTime = time(); $emailTo = "redbrad0@domain.com"; $emailCC = "brad@domain.com"; $emailBCC = "events@domain.com"; $emailSubject = "TEST Email at (" . $currentTime . ")"; $emailBody = "This is the body of the email"; $headers = array(); if (!empty($emailTo)) $headers['TO'] = $emailTo; if (!empty($emailCC)) $headers['CC'] = $emailCC; if (!empty($emailBCC)) $headers['BCC'] = $emailBCC; if (!empty($emailSubject)) $headers['Subject'] = $emailSubject; $headers['From'] = "events@domain.com"; $mime = new Mail_mime("\n"); $mime->setTXTBody($emailBody); $body = $mime->get(); $headers = $mime->headers($headers); $mail = Mail::factory('smtp', array ('host' => 'ssl://smtp.gmail.com', 'auth' => true, 'port' => 465, 'username' => 'events@domain.com', 'password' => 'thepasswordhere')); try { $result = $mail->send($emailTo, $headers, $emailBody); } catch (TixException $ex) { echo "<font color=red>Error:" . $ex->getCode() . "</font><br>"; } echo "Emailed at (" . $currentTime . ")<br>"; die; How can I use an include file that has a list of links in any directory at my website without breaking those links? You can see it in action here... The links in this directory work... https://www.billelgin.com/primary-directory/ The links in this directory (being created from the same include file) do not work... https://www.billelgin.com/primary-directory/subsection-one/ Obviously the problem is the include file is being called from different directories, so it's breaking the relative path links in the include file, but what can I do to fix it? You can download the example directory structure here... https://www.billelgin.com/EXAMPLE.zip I have a notification system that notifies users of new comments, inside the email I have images, some of the logo, some of different people, everything shows up fine on my computer (yahoo email), however in the iPhones email application no images show up, there are just the blue squares with the question marks in them. I'm not sure what I'm missing. Code: [Select] $from = "Kithell <notifications@kithell.com>"; $headers = "From:" . $from ."\r\n"; $headers .= 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $subject = name($from_id, 'fl').$action; $message = '<html><body> <style>@charset "utf-8"; /* CSS Document */ .e-container { background-color: #FFF;position: relative;width: 90%;min-height:1px;margin-right: auto;margin-left: auto; } .e-container .e-m-header { padding: 2px; background-image: url(http://www.kithell.com/assets/tall-grey-header.png); background-repeat: repeat-x; border: 1px solid #CCC; background-position: bottom; display: block; text-align: center; } .e-container p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #666; vertical-align: text-top; display: inline-block; } .e-container .e-usr-photo { display: inline-block; margin: 10px; float: left; background-color: #F4F4F4; } .e-container p a { font-weight: bold; color: #3F60A3; text-decoration: underline; padding: 0px; float: left; margin-top: 0px; margin-right: 5px; margin-bottom: 0px; margin-left: 0px; } .e-container .e-quotes { font-size: 20px; font-weight: bold; color: #999; font-family: Tahoma, Geneva, sans-serif; display: block; padding: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 75px; margin-top:10px; } .e-container .e-message { font-size: 13px; color: #333; padding: 0px; margin-top: 0px; margin-right: 10px; margin-bottom: 0px; margin-left: 10px; clear: none; display: inline; }</style> <div class="e-container"><div class="e-m-header"><img src="http://www.kithell.com/assets/kithell-logo.png" /></div><img class="e-usr-photo" src="http://www.kithell.com/'.photo($from_id, 55).'" /><br /><p><a target="_blank" href="http://www.kithell.com/#/profile&id='.$from_id.'">'.name($from_id, "fl").' </a> '.$action.'<div class="e-quotes">"<p class="e-message">'.nl2br(htmlentities(stripslashes($message))).'</p>"</div></p></div></body></html>'; mail($to,$subject,$message,$headers); <html> <?php $id = $_GET['id']; $dbusername="web148-matt"; $dbpassword="matt"; $dbdatabase="web148-matt"; mysql_connect(localhost,$dbusername,$dbpassword); @mysql_select_db($dbdatabase) or die( "Unable to select database"); mysql_query("UPDATE count SET clicks=clicks+1 WHERE id='$id'"); $sql = mysql_query("SELECT link FROM count WHERE id='$id'"); $fetch = mysql_fetch_row($sql); $result = mysql_query("SELECT * FROM count"); while($row = mysql_fetch_array($result)) { echo "<a href=" .$row['link']. ">Link</a>"; } ?> <a href='http://www.google.com'>Google</a> <a href='/index.php?id=2'>link2</a> </html> for example i have a form like this Code: [Select] <form name="input" action="page2.php" method="post"> <table cellpadding="20" width="100%"> <!-- BEGIN query --> <tr> <td> <img src="../eImages/{IMAGE}.jpg" style="width:200px;height:200px;" /> </td> <td> {EVENTTYPE}</br> {DPLACE} </br> {NAME}</br> {SPEAKERS}</br> {LOC}</br> {STREET}</br> {TIME} </br> </td> <td> <input type="checkbox" name="eventlist"> </td> </tr> <!-- END query --> </table> <input type="submit" value="Submit" /> </form> this is all dynamically loaded each time from a database so it could have several trs of this formal my goal is to only select 3 of them and then submit the form this is will make a checkbox for each one including all the details but the problem is that the checkboxes will all have the same name as oneanother is there a way to increment the checkbox name value each time it goes through the while loop in the database? thanks I'm very new to php. I'm still learning slowly. I'm currently doing a page where im showing all my patient records but there's checkboxes to tick and select a particular patient and go to next page.php to see the details of their history. Here is my codings <?php include ("includes/db.php"); ?> <table width="455" align="center" height="129" border="0" cellpadding="0" cellspacing="1"> <tr> <td width="453"><form name="form1" method="post" action="patienthistory.php"> <table width="900" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF" width="100"><strong>Patient ID</strong></td> <td align="center" bgcolor="#FFFFFF" width="200"><strong>Patient Name</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient I/C</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient Mobile</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Patient Address</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>City</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>State</strong></td> </tr> <?php $sql = "SELECT patient_id, patient_name, patient_ic, patient_mobile, patient_add, patient_city, patient_state FROM patient_healthcare ORDER by patient_id ASC"; $result = mysql_query($sql) or trigger_error(mysql_error(),E_USER_ERROR); while(list($patient_id,$patient_name,$patient_ic,$patient_mobile,$patient_add,$patient_city,$patient_state)=mysql_fetch_row($result)){ $checked="$patient_id" ; echo '<tr><td><input name="checkbox[]" type="checkbox" value="'.$patient_id.'" '.$checked.'/></td><td>'.$patient_id.'</td><td>'.$patient_name.'</td><td>'.$patient_ic.'</td><td>'.$patient_mobile.'</td><td>'.$patient_add.'</td><td>'.$patient_city.'</td><td>'.$patient_state.'</td></tr>'."\n"; } ?> When i tick one boxes and press Select. The next page.php shows all the records. I just want a particular record show not all. Need help. Help is appreciated. how would i get checkboxes to work. I have tried: $JobCategories = ($_GET['JobCategories[]']) ? $_GET['JobCategories[]'] : $_POST['JobCategories[]']; html looks like: <li><input name="JobCategories[]" type="checkbox" value="Admin" /> Admin</li> <li><input name="JoCategories[]" type="checkbox" value="Campaigning" /> Campaigning</li> Okay I am working on a mail script and my only problem is, is that when you select mutiple delete boxes, it only deletes one. How do I get it to delete all of the checked boxes? I am using php to display information from a MySQL database. It starts with three radio buttons and upon selecting one it will display some information for all items in that category. I have all this working but I need to add check boxes for each item and when submitted it will display all information for those items. Below is the bit where I need to insert check box and I'm also attaching my php (leaving out html form and database as it shouldn't be required to help). I must do this as soon as possible, please help. Thanks.. Code: [Select] while ($row = mysql_fetch_assoc ($result_set)) { $ID = $row['id']; $auth = $row['entertainerauthor']; $title = $row['title']; $media = $row['media']; $feature = $row['feature']; printf ("\nID: %s",$ID); printf ("\nEntertainer/Author: %s",$auth); printf ("\nTitle: %s",$title); printf ("\nMedia: %s",$media); printf ("\nFeatu %s",$feature); print "\n"; } Hey Everyone, been a while. I need some help with an easy one. I'm brain farting and blanking out. Someone please help. HTML form that has checkboxes: Code: [Select] <form ...> <input name="check1" type="checkbox" value="Value 1"> </form> PHP Code $post_check1= $_POST["check1"]; $body .= "check1: ".$post_check1."\n"; The form doesn't return the value when checked. What I am missing? I know it's something simple. Please help. Thanks. hi guys....i have a doubt on the checkbox use and validation in php.... how do you enable one checkbox and once it is checked the others would be disabled automatically....... is this possible in php or do we use javascript.... ur guidances and help is appreciated in advance Hey guys I am confused about using checkboxes to delete entries. Yes, just for delete. Codes for table: Code: [Select] echo "<form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\"> <table> <tr> <td width=\"55\" class=\"formLabelsS2\"><input type=\"submit\" name=\"delete\" value=\"Delete\" id=\"delete\"></td> <td> Please note that entries could not be restored once they are deleted!</td> </tr> </table> </form>"; echo "<table class=\"sortable\" id=\"query_quick1\" width=\"100%\" >\r\n"; echo "<thead>"; echo "\t<tr><th></th><th></th><th>Up.dated Query</th><th>Link</th><th>Promoter</th><th> # </th><th>Up?</th> <th>Ana. Area</th><th> # </th><th>Up?</th> <th>C. Type</th><th> # </th><th>Up?</th><th>Other C. Type</th> <th> # </th><th>Up?</th><th>Gen. Back.</th><th> # </th><th>Up?</th> <th>Other Gen. Back.</th><th> # </th><th>Up?</th><th>Author</th><th> # </th><th>Up?</th> <th>Other</th><th> # </th><th>Up?</th><th>Date</th><th>Email</th> <th>F. Name</th><th>L. Name</th></tr>\r\n"; echo "</thead>"; if($result->num_rows){ while ($row = $result->fetch_array()){ $RowCount ++; $row_color = ($RowCount % 2) ? $color1 : $color2; echo "\t<tr class=\"$row_color\" > <form method = \"post\" action=\"{$_SERVER['PHP_SELF']}\"> <td><input type =\"hidden\" name = \"id\" value=\"{$row['id']}\"></td> <td><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"{$rows['id']} \"></td> <td>{$row['query']}</td><td>{$row['link']}</td> <td>{$row['pro']}</td><td>{$row['pro_count']}</td> <td>{$row['pro_update']}</td> <td>{$row['ana']}</td><td>{$row['ana_count']}</td><td>{$row['ana_update']}</td> <td>{$row['cell']}</td><td>{$row['cell_count']}</td><td>{$row['cell_update']}</td> <td>{$row['cellother']}</td><td>{$row['cellother_count']}</td><td>{$row['cellother_update']}</td> <td>{$row['gen']}</td><td>{$row['gen_count']}</td><td>{$row['gen_update']}</td> <td>{$row['genother']}</td><td>{$row['genother_count']}</td><td>{$row['genother_update']}</td> <td>{$row['author']}</td><td>{$row['author_count']}</td><td>{$row['author_update']}</td> <td>{$row['other']}</td><td>{$row['other_count']}</td><td>{$row['other_update']}</td> <td>{$row['date']}</td><td>{$row['Email']}</td> <td>{$row['First_Name']}</td><td>{$row['Last_Name']}</td> </form></tr>"; } } echo "</table>"; php for deleting entries: Code: [Select] } elseif(isset($_SESSION['user_id']) AND isset($_POST['delete'])){ $connect=db_connect_2(); foreach($_POST['checkbox'] as $check) { $delete = mysqli_query("DELETE FROM mailing_list WHERE id = '$check'"); } $body = "mailingList.php"; } Error pops up: Warning: Invalid argument supplied for foreach() Of course no entries are deleted due to this warning. Help would be greatly appreciated as always Thanks. So I have been working on my website for a while which all is php&mysql based, now working on the social networking part building in similar functions like Facebook has. I encountered a difficulty with getting information back from a link. I've checked several sources how it is possible, with title 'Facebook Like URL data Extract Using jQuery PHP and Ajax' was the most popular answer, I get the scripts but all of these scripts work with html links only. My site all with php extensions and copy&paste my site links into these demos do not return anything . I checked the code and all of them using file_get_contents(), parsing through the html file so if i pass 'filename.php' it returns nothing supposing that php has not processed yet and the function gets the content of the php script with no data of course. So my question is that how it is possible to extract data from a link with php extension (on Facebook it works) or how to get php file executed for file_get_contents() to get back the html?
here is the link with code&demo iamusing: http://www.sanwebe.c...-php-and-jquery
thanks in advance.
I am having trouble setting a checkbox to "checked" if the row "published" is set to "1" (0 being not checked). I know this involves an if published==1 then print "checked", but i just cant get it to work. Any help would be greatly apprecatied: <?php include "base.php"; $sql="SELECT * FROM project"; $result=mysql_query($sql); // Count table rows $count=mysql_num_rows($result); ?> <table width="500" border="0" cellspacing="1" cellpadding="0"> <form name="form1" method="post" action=""> <tr> <td> <table width="500" border="0" cellspacing="1" cellpadding="0"> <tr> <td align="center"><strong>Id</strong></td> <td align="center"><strong>title</strong></td> <td align="center"><strong>Published</strong></td> <td align="center"><strong>Promoted</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ $pub = $rows['publised']; ?> <tr> <td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td> <td align="center"><? echo $rows['title']; ?></td> <td align="center"><input name="published[]" type="checkbox" id="published" value="<? echo $rows['published']; ?>"></td> <td align="center"><input name="promoted[]" type="text" id="promoted" value="<? echo $rows['promoted']; ?>"></td> </tr> <?php } ?> <tr> <td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td> </tr> </table> </td> </tr> </form> </table> <?php // Check if button name "Submit" is active, do this if($Submit){ for($i=0;$i<$count;$i++){ $sql1="UPDATE project SET published='$published[$i]', promoted='$promoted[$i]' WHERE id='$id[$i]'"; $result1=mysql_query($sql1); } } if($result1){ header("location:update_multiple.php"); } mysql_close(); ?> Hi, I was wondering if anyone knows how I might do a search in a database from a form using checkboxes, where the code is like this below please? I want to do a database query like this, if firstname is checked, and gender is checked. I want to find someone in the database with that gender and first name only. If all of them are checked, find all matches to that criteria. I think this might be a lot harder than I describe, but that is what I need to do. like this Code: [Select] mysql_query("SELECT users WHERE gender LIKE '%gender%, OR firstname LIKE....." Code: [Select] Search the database by: <form action="search.php" method="post"> <p> <input type="checkbox" name="firstname2" size="20" id="firstname2" value="firstname2" /> First Name<br/> <input type="checkbox" name="lastname2" size="20" id="lastname2" value="lastname2" /> Last Name<br/> <input type="checkbox" name="dob2" size="20" id="dob2" value="dob2" /> Date of Birth<br/> <input type="checkbox" name="gender2" size="20" id="gender2" value="gender2" /> Gender<br/> <input type="submit" name="search" value="Search" /> <input type="reset" name="reset" value="reset" /> </form> Hey I'm trying to send my check-boxes with PHP. Before i added them to my script everything worked fine, i tested the form and i received the answers in my inbox. when i tried to let the checkboxes work, it stopped working. Please help me out! ! I've added this to check my check-boxes: Code: [Select] if ($_POST['Keukens'] == 'on') { $Keukens = "Ja"; } else { $Keukens = "Nee"; } if ($_POST['Badkamers'] == 'on') { $Badkamers = "Ja"; } else { $Badkamers = "Nee"; } if ($_POST['Kasten'] == 'on') { $Kasten = "Ja"; } else { $Kasten = "Nee"; } if ($_POST['Kantoormeubels'] == 'on') { $Kantoormeubels = "Ja"; } else { $Kantoormeubels = "Nee"; } if ($_POST['Tafels'] == 'on') { $Tafels = "Ja"; } else { $Tafels = "Nee"; } if ($_POST['Overige'] == 'on') { $Overige = "Ja"; } else { $Overige = "Nee"; } This is the delivery part: Code: [Select] else { $recipient = "sven@hotmail.com"; //Het email adres van de Ontvanger. $subject = $_POST['sub']; //Onderwerp van de mail. $header = "From: " . $_POST['uwemail'] . "\n"; $mail_body = "Het Contact formulier werd op " . date("d-m-Y") . " om " . date("H:i") . " uur uitgevoerd.\n"; $mail_body .= "De volgende persoon vulde het contact formulier in:\n\n"; $mail_body .= "Voorletters: " . $_POST['voorletters'] . "\n"; $mail_body .= "Achternaam: " . $_POST['naam'] . "\n\n"; $mail_body .= "Adres: " . $_POST['adres'] . "\n"; $mail_body .= "Postcode: " . $_POST['postcode'] . "\n"; $mail_body .= "Woonplaats: " . $_POST['plaats'] . "\n\n"; $mail_body .= "Telefoonnummer: " . $_POST['tel'] . "\n"; $mail_body .= "E-mailadres: " . $_POST['uwemail'] . "\n\n"; $mail_body .= "Onderwerp: " . $_POST['sub']. "\n"; $mail_body .= "Vraag: " . $_POST['field']. "\n\n"; $mail_body .= "Interesses:\n\n"; $mail_body .= "Keukens: ".$Keukens."\n"; $mail_body .= "Badkamermeubels: ".$Badkamermeubels."\n"; $mail_body .= "Kasten: ".$Kasten."\n"; $mail_body .= "Kantoormeubels: ".$Kantoormeubels."\n"; $mail_body .= "Tafels: ".$Tafels."\n"; $mail_body .= "Overige: ".$Overige."\n"; $mail_body .= "\n\n -- Einde van het formulier--"; mail($recipient, $subject, $mail_body, $header); echo "<font color=\"#FFFFFF\"><center><b>Bedankt voor uw reactie.</b><br><br>Wij zullen zo snel mogelijk contact met u opnemen.<br> Met vriendelijke groet,<br>Sven</b><br><br><br>"; echo "Terug naar het <a class=\"main\" href='javascript:history.back(1)'>formulier</a></center></font>"; } } else { ?> This the HTML part: Code: [Select] <font face="Verdana, Arial, Helvetica, sans-serif"> <label> <input type="checkbox" name="Keukens" id="keuze1" value="Keukens"/> <font color="#FFFF00" size="2"> <font size="1">Keukens</font></font></label> <font color="#FFFF00" size="1"><br /> <label> <input type="checkbox" name="Badkamers" id="keuze2" value="Badkamers"/> Badkamermeubels</label> <br /> <label> <input name="Kasten" type="checkbox" id="keuze3" value="Kasten" /> Kasten</label> <br /> <label> <input type="checkbox" name="Kantoormeubels" id="keuze4" value="Kantoormeubels"/> Kantoormeubels</label> <br /> <label> <input type="checkbox" name="Tafels" id="keuze5" value="Tafels"/> Tafels</label> <br /> <label> <input type="checkbox" name="Overige" id="keuze6" value="Overige"/> Overige</label> </font><br /> </font></div> |