Jump to content

Search the Community

Showing results for tags 'checkbox'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

  1. I have the following array: $available_seasons = array ( 0 => array ( 'season_id' => 226, 'season_name' => '2022 - Season 1', 'season_price' => '25.99', 'season_start_date' => 'Jan. 1, 2022', 'season_end_date' => 'Mar. 31, 2022', 'prize' => 100, ), 1 => array ( 'season_id' => 227, 'season_name' => '2022 - Season 2', 'season_price' => '28.99', 'season_start_date' => 'Apr. 1, 2022', 'season_end_date' => 'Jun. 30, 2022', 'prize' => 100, ), 2 => array ( 'season_id' => 238, 'season_name' => '2022 - Season 3', 'season_price' => '40.99', 'season_start_date' => 'Jul. 1, 2022', 'season_end_date' => 'Sep. 30, 2022', 'prize' => 230, ), 3 => array ( 'season_id' => 239, 'season_name' => '2022 - Season 4', 'season_price' => '30.65', 'season_start_date' => 'Oct. 1, 2022', 'season_end_date' => 'Dec. 31, 2022', 'prize' => 300, ), ) I'm using the following loop to create the form: echo "<form name='seasonForm' method=\"post\" action='execute.php'>"; foreach ( $available_seasons as $k => $season ) { echo "<input name='choice' class='uk-checkbox' type='checkbox' value='{$season[ 'season_price' ]}' onchange='checkTotal()'/>"; } echo "<button type='submit'>Continue</button>"; I have the following JS to calculate the total price: function checkTotal() { document.seasonForm.total.value = \'\'; var sum = 0; for (i=0;i<document.seasonForm.choice.length;i++) { if (document.seasonForm.choice[i].checked) { sum = sum + (document.seasonForm.choice[i].value *1); } } document.seasonForm.total.value = "Total: $" + sum; } I am showing the total price to my users, before they click on submit. As it is, I am only able to able to get the value of one checkbox, which is season_price in my execute.php. What I need is to pass the all season_id and season_price values of the selected checkboxes to execute.php. I am not sure how to do this. Thank you for your help in advance.
  2. Hi, I'm trying to check a box in a form based on the $status variable read from a json file. If it's a 1 then the checkbox is checked, otherwise not. If I check/uncheck it, then the $status is written back to the json file. It's a rather simple code but I just cannot get it right. I appreciate any help. TIA <div class="field"> <?php if ($status == 1){ $checked = "checked"; } echo '<input name="ck1" type="checkbox" value='.$status.' '.$checked.' >'; ?> <label for="ck1">Active</label> <!-- <input name='ck1' type='checkbox' <? if $status : "checked" ?> value = "<?=$status ?>" /> --> </div>
  3. Hi guys, I have a huge problem with inserting multiple checked checkboxes into database and thene display checkones on frontend. In other word i have 2 problems regarding these checkboxes. 1. I have 3 checkboxes into user profile panel lets say checkbox 1, checkbox 2, etc. The user select the first 2 ones and inserts them into database. When he returns to his profile to edit his details, i want to display to the user those 2 checkbox that he selected earlier. 2. The secound problem i have is that i have a weekly calendar with week days and some hour intervals. For this the user must select the hours for a day when he is available and on his frontend profile to display them. This is another thing that i can't manage to do, and want a ideea. A print scrit of this calendar is attached to this message.
  4. Hi there guys, I've made some new checkbox fields in my wordpress template using Meta box. Now i want to display those selected checkboxes in the forntend, but it will display only the first checkbox that i've checked, not the other ones. The problem seems to by the array functions that displays only the first checkbox. I'll put bellow the codes that i've been using: This is the code from the meta-box-config.php // General ////////////////////////////////////////////////////////////////////////////////////// array( 'name' => 'Genearal', 'id' => "{$prefix}utilitati_general", 'clone' => false, 'type' => 'checkbox_list', 'options' => array( 'Curent Electric' => __('Curent electric','locality'), 'Telefon' => __('Telefon','locality'), 'Apa' => __('Apa','locality'), 'Gaz' => __('Gaz','locality'), 'Cablu TV' => __('Cablu TV','locality'), 'Canalizare' => __('Canalizare','locality') ), 'std' => false ), This is the code from the frontpage // General ////////////////////////////////////////////////////////////////////////////////////// $locality_utilitati_general = get_post_meta($post->ID, 'locality_utilitati_general', true); if(!empty($locality_utilitati_general)) { ?> <?php _e('General: ','locality'); ?><?php echo implode(',', $_POST['locality_utilitati_general']); ?> <?php }
  5. Greetings All, This place is always so gracious in assisting help to struggling noob developers, I thought i would give this a try. I ran into a wall with my first intranet application. We have a forms library. Which is a basic CRUD set up. A user logs into creates a form. Other users go to edit it. I can't seem to figure out how to have checkboxes/radio buttons populate with the data from my database and be editable. I have each of these checkboxes going in as an array[]. I cant seem to be able to figure out how to see if the option is selected and then show as checked. And if not checked have it appear not checked. I want the update form to appear exactly as the create form but populated with data it was populated with previously. I think half my problem is being able to articulate the issue because google isn't yielding any good results. I would be extremely thankful and grateful to anyone who could point me in the right direction or send me to a good resource. Thank you for your Time.
  6. I am trying to implement the new version of captcha on my website. What i did so far: Inside the FORM: echo '<div class="g-recaptcha" data-sitekey="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"></div>'; Inside PHP: $recaptcha = $_POST['g-recaptcha-response']; if(!empty($recaptcha)) { $google_url = "https://www.google.com/recaptcha/api/siteverify"; $secret = 'YYYYYYYYYYYYYYYYYYYYYYYYYYY'; $ip = $_SERVER['REMOTE_ADDR']; $url = $google_url."?secret=".$secret."&response=".$recaptcha."&remoteip=".$ip; $res = getCurlData($url); $res = json_decode($res, true); if($res['success'] == 'false') { $captcha_error = "Please re-enter your reCAPTCHA."; } } The getCurlData function: function getCurlData($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 10); curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"); $curlData = curl_exec($curl); curl_close($curl); return $curlData; } What i want to achieve is to know when the no-Captcha box is checked. I want to throw an error to the user if he/she did not check that box. So far i only throw an error if the response from Google is "We are not sure if you are human, please proceed to our second level of verification" [if($res['success'] == 'false')]. PS: most of the code is written by Srinivas Tamada. You can find it here. Thanks in advance.
  7. i have checkbox in a table and want to put the value as the id in the database then when i press submit it displays all the row data for each checkbox $res = pg_query ($conn, "SELECT artist,composer,genre,title,album,label,price,description FROM music"); echo "<table border='1'>"; echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>"; while ($row = pg_fetch_row($res)) { echo "<tr>"; echo '<td><input type="checkbox" name="check_list[]" value="' . $row['res'] .'"></td>'; for ($column = 0; $column < pg_num_fields($res); $column++) { echo "<td>" . $row[$column] . "</td>"; } echo "</tr>"; } echo "</table>\n"; ________________________________________________-- basket.php echo "<table border='1'>"; echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>"; echo "<pre>\n"; print_r($_POST['check_list']); echo "</pre>\n";
  8. so i have my database form which you can select a some data using the checkbox and when submitting it should get the row info and display it on the next page iv been struggling for days on this and cant work out how to do it please could i have some help <form name="test" method="post" action="shoppingbasket.php" > <input type="submit" value="Submit" > <?php $conn = pg_connect("host=db.dcs.aber.ac.uk port=5432 dbname=teaching user=csguest password=r3p41r3d"); $res = pg_query ($conn, "SELECT artist,composer,genre,title,album,label,price,description FROM music"); echo "<table border='1'>"; echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>"; while ($row = pg_fetch_row($res)) { echo "<tr>"; echo '<td><input type="checkbox" name="check_list[]" value="' . $row['ref'] . $row['artist'] . '"></td>'; for ($column = 0; $column < pg_num_fields($res); $column++) { echo "<td>" . $row[$column] . "</td>"; } echo "</tr>"; } echo "</table>\n"; ___________________________________________________________________________________________________ shopping basket.php <?php echo "<table border='1'>"; echo "<tr><th>Select</th><th>Artist</th><th>Composer</th><th>Genre</th><th>Title</th><th>Album</th><th>Label</th><th>Price</th><th>Description</th></tr>"; if(!empty($_POST['check_list'])){ foreach($_POST['check_list'] as $row){ echo "$row was checked! "; } } ?> </form> </body> </html>
  9. database.php ________________________________________________________________________________________ $res = pg_query ($conn, "SELECT artist, composer, genre, title, album, label, price, description FROM music"); echo "<table border='1'>"; while($a = pg_fetch_array($res)){ echo "<td>" . $a['1'] . "</td>"; echo "<td>" . $a['2'] . "</td>"; echo "<td>" . $a['3'] . "</td>"; echo "<td>" . $a['4'] . "</td>"; echo "<td>" . $a['5'] . "</td>"; echo "<td>" . $a['6'] . "</td>"; echo "<td>" . $a['7'] . "</td>"; echo '<td><input type="checkbox" name="music[]" value="$ref"' . $row['0'] . $row['1'] . $row['2'] . $row['3'] . $row['4'] . $row['5'] . $row['6'] . $row['7'] . '"/></td>'; echo"</tr>"; } echo "</table>\n"; ?> _____________________________________________________________________________- shoppingbasket.php _____________________________________________________________________________- <form action="shoppingbasket.php" method="POST"> Send To Basket: <name="music"> <input type="submit" value="submit"> </form> cant get it to send data from database to this page shoppingbasket.php if(isset($_POST['music'])){ if (is_array($_POST['music'])) { foreach($_POST['music'] as $row){ echo $row; } } else { $row = $_POST['music']; echo $row; } }
  10. function get_checked($variable, $status){ if($variable == $status){ return 'checked="checked"'; }else{ return ''; } } <input type=\"checkbox\" name=\"emailNewsletter\" value=\"Yes\" ".get_checked($emailNewsletter, 'Yes')."> <input type=\"checkbox\" name=\"emailInbox\" value=\"Yes\" ".get_checked($emailInbox, 'Yes')."> $emailNewsletter = isset($_POST['emailNewsletter']) ? filter_input(INPUT_POST, 'emailNewsletter') : 'No'; $emailInbox = isset($_POST['emailInbox']) ? filter_input(INPUT_POST, 'emailInbox') : 'No'; If no submit button clicked display mysql information $userInfo['emailInbox'] instead of 'NO' . How to do that?
  11. hey guys so im trying to display data into text boxes that are fetched from database according to checkbox with value id. processing is located before <!DOCTYPE html>: if(isset($_POST['edit_event']) && isset($_POST['check'])) { require "connection.php"; foreach ($_POST['check'] as $edit_id) { $edit_id = intval($GET['event_id']); //i tried (int)$edit_id; $sqls = "SELECT event_name,start_date,start_time,end_date,end_time,event_venue FROM event WHERE event_id IN $edit_id "; $sqlsr = mysqli_query($con, $sqls); $z = mysqli_fetch_array($sqlsr); { } button and form opens: <form method="post" action="event.php"> <input type="submit" name="edit_event" value="Edit Event"> this is the html where the data will be echoed: <div id="doverlay" class="doverlay"></div> <div id="ddialog" class="ddialog"> <table class="cevent"> <thead><tr><th>Update Event</th></tr></thead> <tbody> <tr> <td> <input type="text" name="en_" value="<?php echo $z['event_name']; ?>"> </td> </tr> <tr> <td> <input type="text" name="dates_" value="<?php echo $z['start_date']; ?>"> <input type="text" name="times_" value="<?php echo $z['start_time']; ?>"> </td> </tr> <tr> <td><input type="text" name="datee_" value="<?php echo $z['end_date']; ?>"> <input type="text" name="time_" value="<?php echo $z['end_time']; ?>"> </td> </tr> <tr> <td><input type="text" name="ev_" value="<?php echo $z['event_venue']; ?>"> </td> </tr> <tr> <td><input type="submit" name="update" value="Update Event" id="update"> <input type="submit" id="cancelupdate" name="cancel" value="Cancel" > </td> </tr> </tbody> </table> </div> this is the part which is populated by data from database where isset($_POST['check']) gets the 'check' from: echo "<tr> <td><input type='checkbox' name='check[]' value='$id'>$name </td> </tr>"; </form> thanks in advance!
  12. Hi I wondering what i did wrong here: I wont to register 1 or 0 into database. Checkbox file: <?php include("db-tilkobling.php"); $sqlSetning="SELECT * FROM Kvarterbestilt ORDER BY Møtt;"; $sqlResultat=mysqli_query($db,$sqlSetning) or die ("Ikke mulig å hente data fra databasen"); $antallRader=mysqli_num_rows($sqlResultat); print("<input type='checkbox' name='møtt' value='$møtt'>"); ?> Register-møtt.php <?php include("start.html"); ?> <br/> <p>Registrer Møtt/Ikke møtt ved å fylle ut skjemaet under</p> <form method="post" action="" id="registrerAnsattSkjema" name="registrerAnsattSkjema"> <fieldset> <legend>Registrer møtt / ikke møttt</legend> <label for="personnummer">Personnummer</label> <?php include("listeboks-personnummer.php"); ?><br/> <label for="timenummer">Timenummer</label> <?php include("listeboks-timenummer.php"); ?><br/> Sjekk av denne boksen hvis pasient har møtt til time:<br/> <?php include("checkbox-møtt.php"); ?><br/> <input type="submit" name="registrerMottKnapp" id="registrerMottKnapp" value="Registrer møtt/ikke"> <input type="reset" name="nullstill" id="nullstill" value="nullstill"> </fieldset> </form><br/> <?php /* include("valider-mott.php");*/ $registrerMottKnapp=$_POST ["registrerMottKnapp"]; if ($registrerMottKnapp) { $personnummer=$_POST["Personnummer"]; $timenummer=$_POST["Timenummer"]; $møtt=$_POST["Møtt"]; } if ($møtt == '1') { $query = mysql_query("INSERT INTO Kvarterbestilt(Møtt) VALUES('1')"); } /* $lovligFornavn=validerFornavn ($fornavn); $lovligFornavn2=validerFornavn2 ($fornavn); $lovligFornavn3=validerFornavn3 ($fornavn); $lovligEtternavn=validerEtternavn ($etternavn); $lovligEtternavn2=validerEtternavn2 ($etternavn); $lovligEtternavn3=validerEtternavn3 ($etternavn); $lovligYrke=validerYrke ($yrke); $lovligYrke2=validerYrke2 ($yrke); $lovligYrke3=validerYrke3 ($yrke); if (!$lovligFornavn) { print("Fornavn er ikke fylt ut! <br/>"); } else if (!$lovligFornavn2) { print("Bare bokstaver og mellomrom er tillat; $fornavn<br/>"); } else if (!$lovligFornavn3) { print("Ingen tall tillat; $fornavn<br/>"); } else if (!$lovligEtternavn) { print("Etternavn er ikke fylt ut!<br/>"); } else if (!$lovligEtternavn2) { print("Bare bokstaver og mellomrom er tillat; $etternavn<br/>"); } else if (!$lovligEtternavn3) { print("Ingen tall tillat; $etternavn<br/>"); } else if (!$lovligYrke) { print("Yrke er ikke fylt ut!<br/>"); } else if (!$lovligYrke2) { print("Bare bokstaver og mellomrom er tillat; $yrke<br/>"); } else if (!$lovligYrke3) { print("Ingen tall tillat; $yrke<br/>"); } */ /* include("db-tilkobling.php"); $check=mysqli_query($db,"SELECT * FROM Kvarterbestilt WHERE Personnummer='$personnummer' AND Timenummer='$timenummer'"); $checkrows=mysqli_num_rows($check); if($checkrows>0){echo "Ansatt eksiterer fra før";} else { $sqlSetning="INSERT INTO Kvarterbestilt(Møtt) WHERE Personnummer='$personnummer' VALUES ('$møtt');"; mysqli_query ($db,$sqlSetning) or die ("Ikke mulig Ã¥ registrere i db"); print ("Det er registrert at pasienten har $møtt til timen $timenummer"); } } */ include("slutt.html"); ?>
  13. I have this code: checkbox : function(elem) { $(function() { var isChecked = elem.checked, $check = $(this).val(), $address = $('.'+ elem.id); $image = $('.imagenone'); if(isChecked) { $address.stop().fadeIn("slow").css("display","inline-block"); $image.stop().fadeOut("slow").css("display","none"); } else { $address.stop().fadeOut("slow"); } }); } I need check if id of "$address"(class) displayed, not display other div with same id. I have a "query" which lists all the "rows" of the table, each "row" has a sub-category and associated product, which in my case the sub-category is the class and id is the product. but for different sub-categories can have the same product, not wanting to give the same id / product appear in duplicate. the problem is that there are only checkboxes for sub-categories, where the purpose is to create a filter. where all products with this sub-category, choosing more than one sub-category to check the sub-category appear. In different sub-category may contain the same products, just wanting to appear only once, and not repeated, ie not appear divs with the same id (same product) in duplicate. Structure Product List - http://s30.postimg.org/p0j37jl01/coding.jpg ps: sorry my bad english !
  14. How could I declare checkbox, if checkbox is checked = 1 else = 0.And insert to mySQL. <input type="checkbox" name="homepage" value="1" /> <-----this is my checkbox code. Only this i know. somemore,if i already insert data to mySQL, how could i display checkbox is checked based on database, 1 = checked, 0 = unchecked. I had try many code,but it won't work as well..Now i've no idea. P/S:I'm using php code. Please help. Thanks. Regards.
  15. I have checkbox function that creates a checkbox list from my database. I also have a map that I want onclick to check the checkbox align with that section of the map. So if you click Bominvile on the map the checkbox for Bominville gets checked/unChecked. [FUNCTION CALL] (From db.php) / This will create a CHECK BOX based on the property/value pairs in table AND the toggle all checkbox. function buildCheckBox($table, $prechecked) { $conn = db_connect(); // establish connection $sql = "SELECT property, value FROM ".$table.""; $results = pg_query($conn, $sql); //THIS LOOP ONLY RUNS ONCE ON PAGE LOAD. JUST TO DISPLAY // THE REORDS IN THE CITY DB TABLE. while ($record = pg_fetch_array($results)) { $checked = ($prechecked == $record['value'])?"checked=\"checked\"":""; echo '<input type="checkbox" name="'. $table.'[]" ' .$checked.' value="'. $record['value'] .'">'. $record['property'] .'<br/>'; } //echo "show me whats record ". $record['property']. "<br/>"; } [/FUNCTION] <script language="javascript"> function myclick(whichone) { if (document.getElementById(whichone).checked == true) { document.getElementById(whichone).checked = false; } else { document.getElementById(whichone).checked = true; } } </script> <tr> <td class="left"> <input type="checkbox" id="city_toggle" onclick="cityToggleAll();" name="city[]">City Toggle All<br/> <!-- FUNCTION CALL TO LOOP THROUGH TOGGLING CHECK BOXES ON/OFF--> <?php echo buildCheckBox('city', $selected_city);?> <input type="checkbox" id="city[]"><br> </td> <td><img src="pictures/durham_mapgoodbeforewhitby.png" alt="durham_map" width="417" height="340" usemap="#map1"> <a href="#" onClick="myclick('city[]')"> <map name="map1"> <area shape="poly" coords="193,207,284,207,391,214,190,287,260,299,300,307,344,310,389,322" href="#" id="city[]" title="Bowmanville" alt="Bowmanville" /> </map> </a><br> </td> </tr>
  16. Im now making a simple project called student attendance.. I've just managed the register/login part.. Right now, these are the tables that i created so far.. http://i272.photobucket.com/albums/jj178/r1nk_2008/1_zpsf1765f1c.png http://i272.photobucket.com/albums/jj178/r1nk_2008/2_zpsa1a1310a.png http://i272.photobucket.com/albums/jj178/r1nk_2008/3_zps092b7ff1.png http://i272.photobucket.com/albums/jj178/r1nk_2008/4_zps1fffbc49.png What i need right now is some advice on how :- The lecturer can select the course_id that have been assigned and then list of subject he/she teach will appear.. Based on what subject he/she clicked, an attendance table appear with list of students in that class and week 1- week XX (checkbox for attendance).. Do i need to assign some primary and foreign key in my tables or adding some more necessary tables?
  17. Well I am having the worst weekend ever. I have been working on this code all day and google is not my friend today. So here is the problem, I am trying to write a form that is basically keeping records of people who have stayed as guest and what meals they ate (breakfast, lunch, dinner, midnight snack). So the html form is pretty simple, and I have a few checkboxes and a little javascript to add more rows if there are more guest. Everything is working fine, but the checkboxes values are killing me. Basically if the box isnt checked than do what? Anyway my insert isnt working at all Anyway here is some basic coding Html form for checkboxes: <td><input type="checkbox" name="breakfast[]" /></td> <td><input type="checkbox" name="lunch[]" /></td> <td><input type="checkbox" name="dinner[]" /></td> <td><input type="checkbox" name="midnight[]" /></td> <td><input type="checkbox" name="lodging[]"/></td> <td><input type="text" name="guestName[]"/></td> So as you can see checkboxes for the meals and a text input for the guest name. Now here is my function (please go easy I am new to pdo) public function createMeal($id,$table){ try{ //write query if(isset($_POST['guestName'])){ $guestName = $_POST['guestName']; $repName = $_POST['repName']; $repTitle = $_POST['repTitle']; if(isset($_POST['breakfast'])){ $breakfast = $_POST['breakfast']; } if(isset($_POST['lunch'])){ $lunch = $_POST['lunch']; } if(isset($_POST['dinner'])){ $dinner = $_POST['dinner']; } if(isset($_POST['midnight'])){ $midnight = $_POST['midnight']; } if(isset($_POST['lodging'])){ $lodging = $_POST['lodging']; } } foreach($guestName as $a => $b) { $query = "INSERT INTO meals(repName, repTitle, breakfast, lunch, dinner, midnight, lodging, guestName, masterLogID) VALUES (:repName, :repTitle, :breakfast, :lunch, :dinner, :midnight, :lodging, :guestName, :masterLogID)"; $stmt = $this->conn->prepare($query); $stmt->bindParam(':repName',$repName[$a]); $stmt->bindParam(':repTitle',$repTitle[$a]); $stmt->bindParam(':breakfast',$breakfast[$a]); $stmt->bindParam(':lunch',$lunch[$a]); $stmt->bindParam(':dinner',$dinner[$a]); $stmt->bindParam(':midnight',$midnight[$a]); $stmt->bindParam(':lodging',$lodging[$a]); $stmt->bindParam(':guestName',$guestName[$a]); $stmt->bindParam(':masterLogID',$masterLogID); // Execute the query $stmt->execute(); } echo "Record was saved."; }catch(PDOException $exception){ //to handle error echo "Error: " . $exception->getMessage(); } } I am getting the message "Record was saved", but nothing is in the table. Any help is greatly appreciated
  18. The program MUST use functions to calculate the cost of the conference, and to calculate the cost of meals. The functions should return the calculated costs back to the main program. I am trying to use checkboxes to for the input.. Im new to all of this trying to get it right.. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <style> body { color:black; font-size:20px; } h1 { color:orange; text-align:center; font-size:30px; } p { font-family:"Times New Roman"; font-size:20px; } </style> <title>MAJOR PROJECT 1 PHP </title> </head> <body> <h1>Nerd Roundup </h1> <form method = "POST" action = "http://localhost/Assignments php class/calculationprogress.php"> <fieldset> <label> Please type your first name: </label> <input type = "text" name = "fName" value = "" /> <br /> <label> Please type your Last name: </label> <input type = "text" name = "lName" value = "" /> <br /> Please type your city: <input type = "text" name = "city" value = "" /> <br /> Please type your State: <input type = "text" name = "state" value = "" /> <br /> Please type your Zipcode: <input type = "text" name = "zipCode" value = "" /> <br /> <label for="other">Anything else you want to add?</label> <textarea id="other" name="other"></textarea><br /> <fieldset> <legend>HOW MANY DAYS</legend> <input type = "checkbox" name = "chkOne" value = "100.OO" /><label>ONE DAY $100.00</label> <input type = "checkbox" name = "chkTwo" value = "175.00" /><label>TWO DAYS $175.00</label> <input type = "checkbox" name = "chkThree" value = "325.00" /><label>THREE DAYS $325.00</label> <br /> <fieldset> <legend>DO YOU WANT THE MEAL PLAN?</legend> <input type = "checkbox" name = "mealPlan" value = "mealPlan" /><label>YES</label> <input type = "checkbox" name = "" value = "no" /><label>NO</label> <br /> <br /> <h1>NERD TRACK</h1> <select name = "track"> <option value = "PROGRAMMING TRACK">PROGRAMMING TRACK</option> <option value = "NETWORKING TRACK">NETWORKING TRACK</option> <option value = "SECURITY TRACK">SECURITY TRACK</option> <option value = "WEB TRACK">WEB TRACK</option> </select> <button type = "submit"> place order </button> </fieldset> </form> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <style> body { background-color:#FF00FF; } h1 { color:orange; text-align:center; } p { font-family:"Times New Roman"; font-size:20px; } h1 {text-align:center; } </style> <title>Assignment3</title> </head> <body> <h1>Personal Information </h1> <?php // define the variables $fName = $_POST["fName"]; $lName = $_POST ["lName"]; $city = $_POST ["city"]; $state = $_POST ["state"]; $zipCode = $_POST["zipCode"]; $other = $_POST ["other"]; $chkOne = $_POST["chkOne"]; $chkTwo = $_POST["chkTwo"]; $chkThree = $_POST["chkThree"]; $mealPlan = $_POST[""]; $confTotal = 0; $no_errors = TRUE; $total = 0; //begin form filter if (filter_has_var(INPUT_POST, "chkOne")){ print "<p>ONE DAY CONFERENCE</p> \n"; $total += filter_input(INPUT_POST, "chkOne"); } if (filter_has_var(INPUT_POST, "chkTwo")){ print "<p>TWO DAY CONFERENCE</p> \n"; $total += filter_input(INPUT_POST, "chkTwo"); } if (filter_has_var(INPUT_POST, "chkThree")){ print "<p>THREE DAY CONFERENCE</p> \n"; $total += filter_input(INPUT_POST, "chkThree"); } //end $total if (filter_has_var(INPUT_POST, "mealPlan")){ } if (filter_has_var(INPUT_POST, "noFood")){ } // do they want the meal plan $track = filter_input(INPUT_POST, "track"); // what conference track are they on if(empty($fName)) { $no_errors = FALSE; echo '***FIRST NAME FIELD REQUIRED***** <br />' ; } //get users first name if(empty($lName)) { $no_errors = FALSE; echo '****LAST NAME FIELD REQUIRED***** <br /> '; } // get users last name if(empty($city)) { $no_errors = FALSE; echo '****CITY FIELD REQUIRED***** <br /> '; } //get user city if(empty($state)) { $no_errors = FALSE; echo '***STATE NAME FIELD REQUIRED***** <br /> '; } //get user state if(empty($zipCode)) { $no_errors = FALSE; echo '****ZIPCODE FIELD REQUIRED***** <br /> '; } //get user zip code if(empty($other)) { $no_errors = FALSE; echo '****TEXT FIELD REQUIRED***** <br /> '; } //get user additional comments if ($no_errors == FALSE) { echo "<br> <a href='major1progress.html'>Go back to form</a>"; } // check the fields are all filled if not direct back to form page //beging function calculateCost function calculateCost() global $total; $total = filter_input (INPUT_POST, "total"); $mealPlan = filter_input (INPUT_POST, "mealPlan"); IF (! filter_has_var (INPUT_POST, "mealPlan" )){ && $total =="100" ,$confTotal = $total+= 50; } else if ($total=="175"){ $confTotal = $total +=75; } else if ($total =="225"){$confTotal = $total +=100; } //end function cacluclateCost //end if //1 to 1000 $confId = rand(1,1000); //generate conf id number if ($no_errors == TRUE) { print " <p> $fName $lName, <br />you have registered for Nerd Roundup 2013<br /> your planned track is $track<br /> <br /> You choose -confDay<br /> with -mPlan<br /> The total cost is: \$$confTotal <br /> I hear the climate around $zipCode is great this time of year. <br /> Please make sure to bring cash, or your credit card to pay for the conference on the first day<br /> Your additional comments are as follows: $other <br /> </p> <p>Your Nerd Roundup confirmation number is $confId .</p> <br /> \n"; } //check and see is the form filled out if it is then print stuff ?> </body> </html> //beging function calculateCost function calculateCost() global $total; $total = filter_input (INPUT_POST, "total"); $mealPlan = filter_input (INPUT_POST, "mealPlan"); IF (! filter_has_var (INPUT_POST, "mealPlan" )){ && $total =="100" ,$confTotal = $total+= 50; } else if ($total=="175"){ $confTotal = $total +=75; } else if ($total =="225"){$confTotal = $total +=100; } //end function cacluclateCost
  19. Can anybody help me to check what's wrong with the coding. First, i get the value of checkbox from the previous page. So, if checkbox 1 and 2 is selected, result with result_id 4 will be shown. if checkbox 1 and 3 is selected, result with result_id 5 will be shown. Now the problem is...no matter which checkbox is selected, the program will only run 'if statement' , which is result_id 4. Below is the coding. Hope you guys can help me. >< .Thank alot!! <?php session_start(); if(isset($_GET['checkbox'])){ $checkbox = $_GET['checkbox']; } else { header('Location:tutorial.php'); } include("database.php"); for($i=0; $i < count($checkbox); $i++){ { if ($checkbox[$i]= '1' && $checkbox[$i]= '2'){ $sql="SELECT * FROM result WHERE result.result_id = 4";} elseif ($checkbox[$i]='1' && $checkbox[$i]= '3'){ $sql="SELECT * FROM result WHERE result.result_id = 5";} else {} } } $result=mysql_query($sql); echo "<form action = 'result.php' method='POST'> <br/>"; echo "<table>"; while($row = mysql_fetch_array($result)) { $result_name=$row['result_name']; $result_id=$row['result_id']; $result_desc=$row['result_desc']; $image=$row['image']; echo "<h4>$result_name</h4> "; echo "<tr >"; echo "<td>"; echo "</form>";?> <img src="<?php echo $row ["image"];?>" width="500" height = "600" align="left" border="1" /><?php echo "</td>" ; echo "</tr>"; } echo "</table>"; ?>
  20. Hey guys, As you can see i have a form im trying to use for a user to change or update their profile settings. i know in using php / mysql you can set the default value in the forms for say names and email and what not. is there a way to do that for check boxes and buttons ? if you see my form below, i have added in the php logic for the first code. i just am confused as to a way to set all the fields to having a default. i figure this is the easiest way to not have to write a whole bunch of conditionals to make sure if a person doesnt input a value in the update fields, it will just make the field in the database blank as well. i figure i rather have them just re-input the data back that will just show up as the default anyway. thanks guys <tbody><tr> <td class="register_td_left"><span class="">Email Address:</span></td> <td class="register_td_right" colspan="2"><input type="email" name="update_email" size="35" maxlength="50" value="<? echo $user_data['email']; ?>"></td> // HERE I ADDED PHP, TO GRAB FROM MYSQL </tr> <tr> <td class="register_td_left"></td><td class="extra_data2" colspan="2"> </td> </tr> <td class="register_td_left"><span class="">Gender:</span></td> <td class="register_td_right" colspan="2"> <input id="male" name="gender" type="radio" value="m"><label for="male"> Male</label> <input id="female" name="gender" type="radio" value="f"><label for="female"> Female</label> </td> <tr> <td class="register_td_left"></td><td class="extra_data2" colspan="2"> </td> </tr> <tr> <td class="register_td_left"><span class="">Date of Birth:</span></td> <td class="register_td_right" colspan="2"><select name="month" id="month" style="width:100px"><option value="">---</option><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select><select name="date" id="date" style="width:45px"><option value="">---</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select><select name="year" id="reg-year" style="width:60px"><option value="">---</option><option value="2016">2016</option><option value="2015">2015</option><option value="2014">2014</option><option value="2013">2013</option><option value="2012">2012</option><option value="2011">2011</option><option value="2010">2010</option><option value="2009">2009</option><option value="2008">2008</option><option value="2007">2007</option><option value="2006">2006</option><option value="2005">2005</option><option value="2004">2004</option><option value="2003">2003</option><option value="2002">2002</option><option value="2001">2001</option><option value="2000">2000</option><option value="1999">1999</option><option value="1998">1998</option><option value="1997">1997</option><option value="1996">1996</option><option value="1995">1995</option><option value="1994">1994</option><option value="1993">1993</option><option value="1992">1992</option><option value="1991">1991</option><option value="1990">1990</option><option value="1989">1989</option><option value="1988">1988</option><option value="1987">1987</option><option value="1986">1986</option><option value="1985">1985</option><option value="1984">1984</option><option value="1983">1983</option><option value="1982">1982</option><option value="1981">1981</option><option value="1980">1980</option><option value="1979">1979</option><option value="1978">1978</option><option value="1977">1977</option><option value="1976">1976</option><option value="1975">1975</option><option value="1974">1974</option><option value="1973">1973</option><option value="1972">1972</option><option value="1971">1971</option><option value="1970">1970</option><option value="1969">1969</option><option value="1968">1968</option><option value="1967">1967</option><option value="1966">1966</option><option value="1965">1965</option><option value="1964">1964</option><option value="1963">1963</option><option value="1962">1962</option><option value="1961">1961</option><option value="1960">1960</option><option value="1959">1959</option><option value="1958">1958</option><option value="1957">1957</option><option value="1956">1956</option><option value="1955">1955</option><option value="1954">1954</option><option value="1953">1953</option><option value="1952">1952</option><option value="1951">1951</option><option value="1950">1950</option><option value="1949">1949</option><option value="1948">1948</option><option value="1947">1947</option><option value="1946">1946</option><option value="1945">1945</option><option value="1944">1944</option><option value="1943">1943</option><option value="1942">1942</option><option value="1941">1941</option><option value="1940">1940</option><option value="1939">1939</option><option value="1938">1938</option><option value="1937">1937</option><option value="1936">1936</option><option value="1935">1935</option><option value="1934">1934</option><option value="1933">1933</option><option value="1932">1932</option><option value="1931">1931</option><option value="1930">1930</option><option value="1929">1929</option><option value="1928">1928</option><option value="1927">1927</option><option value="1926">1926</option><option value="1925">1925</option><option value="1924">1924</option><option value="1923">1923</option><option value="1922">1922</option><option value="1921">1921</option><option value="1920">1920</option><option value="1919">1919</option><option value="1918">1918</option><option value="1917">1917</option><option value="1916">1916</option><option value="1915">1915</option><option value="1914">1914</option><option value="1913">1913</option><option value="1912">1912</option><option value="1911">1911</option><option value="1910">1910</option><option value="1909">1909</option><option value="1908">1908</option><option value="1907">1907</option><option value="1906">1906</option><option value="1905">1905</option><option value="1904">1904</option><option value="1903">1903</option><option value="1902">1902</option><option value="1901">1901</option><option value="1900">1900</option><option value="1899">1899</option><option value="1898">1898</option><option value="1897">1897</option><option value="1896">1896</option></select></td> </tr>
  21. I have made a page that lists all the products in a MySQL database as a form, so the user can amend details as they view it, this I've done by listing each row in the table as a form, with a selection of buttons on the end; this strategy has worked for me very well for the last few weeks, however I have decided to add check-boxes to the page, and when submitting a form on one of the rows of the table, the form submits all of the check-boxes for some reason; its taken me a day to figure out that this was why I was getting peculiar behaviour from the php code that deals with the results of the form on the next page. The checkboxes are pre-checked with the information from the database, the idea was to have the details in the 'group' column change when the selection of check-boxes were changed, however, although the database is read correctly, and the checking on check-boxes works, when the form is submitted the form submits all of the selections on the entire page across all of the forms. The code for the form is as follows: echo "<form action='action.php?part=$group' method='post'>"; echo "<table>"; echo "<tr align=center><td>Part No</td><td>Description</td><td>Stock</td><td>Notes</td> <td align='center' title='ProductLine1'>L</td> <td align='center' title='ProductLine2'>R</td> <td align='center' title='ProductLine3'>S</td> <td align='center' title='ProductLine4'>V</td> <td align='center' title='ProductLine5'>Z</td> <td align='center' title='ProductLine6'>U</td> <td align='center' title='ProductLine7arts'>P</td> <td align='center' title='ProductLine8'>X</td> </tr>"; while ($row = mysql_fetch_assoc($result)) { echo "<tr>"; //MAIN FORM echo "<td><input type='text' name='company_PartNo' maxlength='10' value='$row[company_PartNo]' size='3' readonly /></td>"; echo "<td><input type='text' name='Part_Name' maxlength='65' value='$row[Part_Name]' size='30' readonly /></td>"; echo "<td><input type='text' name='Stock' maxlength='10' value='$row[Stock]' size='3' /></td>"; echo "<td><input type='text' name='Notes' maxlength='65' value='$row[Notes]' size='30' /></td>"; //SYSTEM echo "<td><input type='checkbox' name='system[]' title='ProductLine1' value='PL1' "; if (strpos($row['group'],'Prod1') !== false) { echo "checked></td>";} else { echo "></td>";} echo "<td><input type='checkbox' name='system[]' title='ProductLine2' value='PL2' "; if (strpos($row['group'],'Prod2') !== false) { echo "checked></td>";} else { echo "></td>";} echo "<td><input type='checkbox' name='system[]' title='ProductLine3' value='PL3' "; if (strpos($row['group'],'Prod3') !== false) { echo "checked></td>";} else { echo "></td>";} echo "<td><input type='checkbox' name='system[]' title='ProductLine4' value='PL4' "; if (strpos($row['group'],'Prod4') !== false) { echo "checked></td>";} else { echo "></td>";} echo "<td><input type='checkbox' name='system[]' title='ProductLine5' value='PL5' "; if (strpos($row['group'],'Prod5') !== false) { echo "checked></td>";} else { echo "></td>";} echo "<td><input type='checkbox' name='system[]' title='ProductLine6' value='PL6' "; if (strpos($row['group'],'Prod6') !== false) { echo "checked></td>";} else { echo "></td>";} echo "<td><input type='checkbox' name='system[]' title='ProductLine7' value='PL7' "; if (strpos($row['group'],'Prod7') !== false) { echo "checked></td>";} else { echo "></td>";} echo "<td><input type='checkbox' name='system[]' title='ProductLine8' value='PL8' "; if (strpos($row['group'],'Prod8') !== false) { echo "checked></td>";} else { echo "></td>";} //BUTTONS echo "<td><input type='submit' name='store' value='Store'/> <input type='submit' name='delete' value='Delete'/> <input type='submit' name='edit' value='Edit'/> <input type='submit' name='move' value='Move'/></td>"; //HIDDEN DETAILS /* echo " <div style='height:0px;width:0px;'> <input type='text' name='PartID' maxlength='65' style='visibility:hidden;' value='$row[PartID]' size='1'/> </div>"; */ echo "</tr>"; } echo "</table>"; echo "</form>"; Can someone help me bring order to this chaos?
  22. Hello fellow PHP developers. I have been stuck on a problem I just can not figure out. I am developing a couple forms (insert and update) that users fill out. On this form is general user information (first and last name fields, etc.) as well as a checkbox group based on an available “groups” table. When the user fills out the form and makes their checkbox selections I write the user information to a user table, and write the user’s checkbox choices to a user_group_xref table (unique_id, fk_user_id, fk_group_id) for as many choices as the user selected. The fk_user_id is a foreign key to the user table, and the fk_group_id is a foreign key to the group table. User_table Unique_id, first_name, last_name, address Groups_table Unique_id, group_description, active_flag User_group_xref table Unique_id, fk_user_id, fk_group_id This all works correctly for the insert, and I can make the selections out of the tables no problem. To get the users previous selections, I query the xref table and join it back to the group table for the description. My user_groups query returns g.unique_id, g.group_description for the appropriate user. I generate the checkboxes with the following code: <?php do { ; ?> <br /> <label> <input type="checkbox" name="admin_groups[]" value="<?php echo $row_groups['pkID']; ?>" id="admin_groups_<?php echo $row_groups['pkID']; ?>" tabindex="<?php echo $iTabIndexCounter;?>" /> <?php echo $row_groups['group_description']; ?> </label> <?php } while ($row_groups = mysql_fetch_assoc($groups)); ?> This works fine in generating the checkboxes. How do I at the same time check those checkboxes previously selected? The only thing I can think of is to show only those checkboxes actually selected, but I want all checkboxes displayed, and those previously selected checked. Any suggestions would be greatly appreciated.
  23. Hi, I'm trying to make a form that validates any errors on a page then submits the data via a $_SESSION to the next page for further review. I'm at the point where I'm trying to make it so that if there are any errors on the first page that form information isn't lost when the page reloads. So far this is fine for my text fields, drop down boxes etc, however I'm having issues with my check boxes. If they have been checked and submitted and the admin wants to uncheck it, when the page reloads it still comes back as being checked which means my code for unsetting the variable isnt working for whatever reason. Heres my code. <?php require_once("includes/session.php"); ?> <?php if(isset($_POST['submit'])) { $errors = array(); $required_fields = array( 'brand_id', 'dev_model', 'freq_2g_gsm850', ); //If any of the required fields are not set or empty, put them into an errors array and clear the $_SESSION variable foreach($required_fields as $fieldname) { if (!isset($_POST[$fieldname]) || empty($_POST[$fieldname])) { $errors[] = $fieldname; unset($_SESSION['$fieldname']); } } //If there are no errors go ahead and process the data if (empty($errors)) { //Process each variable and add it to the Session for the next page to process *** Might be able to remove if(isset) foreach($required_fields as $fieldname) { if (isset($_POST[$fieldname])) { $_SESSION[$fieldname] = mysql_prep($_POST[$fieldname]); } } //Redirect to posttest.php to complete the device registration form redirect_to('posttest.php'); } else { foreach($required_fields as $fieldname) { if (isset($_POST[$fieldname])) { $_SESSION[$fieldname] = mysql_prep($_POST[$fieldname]); } } //unset($_SESSION['$freq_2g_gsm850']); //Errors occured $message = "There were " . count($errors) . " errors in the form"; } } ?> <h3>2G GSM</h3> <?php if(!isset($_SESSION['freq_2g_gsm850']) || empty($_SESSION['freq_2g_gsm850'])) { echo "<label><input type=\"checkbox\" name=\"freq_2g_gsm850\" value=\"850\" id=\"freq_2g_gsm850\">850</label>"; } else { echo "<label><input type=\"checkbox\" name=\"freq_2g_gsm850\" value=\"850\" id=\"freq_2g_gsm850\" checked>850</label>"; } ?> Thanks in advance for your help
  24. Guys, I'm a newbie. There, I got that out of the way.... I have a form that can be submitted and then modified. The data gets sent to a mySQL db. It's nothing special. The idea is that the user is to click a checkbox located at the bottom of the form that says "I'm finished with my project" when checked the stored value is "yes". Everything works fine the value gets stored and all is well except I can not get the darn thing to echo the chekced value. Below is what I have tried with no joy. <input type="checkbox" name="projectcomplete[]" <?php if ($user_type_detail["projectcomplete"]=='Yes') {echo "checked";} ?>> Why the heck won't it work? The value "yes" is stored. Arrrggggg.... I also tried isset with no joy... <input type="checkbox" name="projectcomplete" <?php if (isset($yes)) { echo 'value="checked"'; }?> > The following code below works perfectly on the form. I have refferenced it but no solution materialized. What can I tell ya.. I'm a newb... I don't have the skills to uncover the solution. input type="radio" class="radio" name="CYSD_Particiapant" value="Yes" <?php if($user_type_detail["CYSD_Particiapant"]=='Yes') echo 'checked=checked';else echo '';?> />Yes<input class="radio" type="radio" name="CYSD_Particiapant" value="No" <?php if($user_type_detail["CYSD_Particiapant"]=='No') echo 'checked=checked';else echo '';?> />No Any help would be very much appriated.
  25. I'm trying to include a checkbox group in a form submission. The user can check one, two, or all three of the choices. I need only the checked boxes to how can i do that? help me with a small example if possible so that i can nderstand well,plzzz. Thank you!
×
×
  • 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.