PHP - Error Wont Send Checkbox Value To Next Page
database.php
Similar Tutorialsguys, in the code below (this is just a demonstration) i need to find out once a card payment has been done, the code changes the status of the order but it doesnt send email. can u please help me find out why? <?php session_start(); include ("includes/db.php"); include ("includes/function.php"); //authentication if (loggedin()==FALSE) { Header("Location: login.php"); exit(); } //username session $_SESSION['username']=='$username'; $username=$_SESSION['username']; echo "Welcome, " .$_SESSION['username']."!<p>"; //get user id $getdetails=mysql_query("SELECT * FROM users WHERE username='$username'"); while($row = mysql_fetch_array($getdetails)) { $users_id=$row['id']; $email=$row['email']; } $getdetails=mysql_query("SELECT * FROM booking WHERE users_id='$users_id' AND status='pending'"); $totaloforders=mysql_num_rows($getdetails); while($row = mysql_fetch_array($getdetails)) { $users_id=$row['id']; $bookedtime=$row['time']; $bookeddate=$row['date']; $bookedseat=$row['seat_no']; echo " <td>Swinging For Seat: $bookedseat on $bookeddate at $bookedtime</td><br/> "; echo "</table>"; } //get the firstname $myfirstname=$_SESSION ['firstname']; //get the lastname $mylastname=$_SESSION ['lastname']; //get the email $myemail=$_SESSION ['email']; //get the seat number $myseatnumber=$_SESSION ['seatnumber']; //get the booking time $mytime=$_SESSION ['time']; //get the booking date $mybookingdate=$_SESSION ['datetime']; //get the ride id $ride=$_SESSION ['ride']; //get the bookings $select=mysql_query("SELECT * FROM booking WHERE users_id='$users_id'"); while ($row=mysql_fetch_array($select)){ $id=$row['id']; $date=$row['$date']; $time=$row['time']; } /////////////////////////////////////////////////////////////////////////////////////////////// // Calculate the price plus VAT, VAT at current time is 20% of each service $price=mysql_query("SELECT price FROM ride_type WHERE id='$ride'"); while ($row=mysql_fetch_array($price)){ $rideprice=$row['price']; } $net=$totaloforders*$rideprice; $vat=$net*20/100; $finalprice=$net+$vat; ////////////////////////////////////////////////////////////////////////////////////////////// if ($_POST['pay']) { /** Validation */ $cardNo = addslashes(strip_tags($_POST['cardNo'])); $cc = addslashes(strip_tags($_POST['cc'])); $expire = addslashes(strip_tags($_POST['expire'])); if ($cardNo == "" ||$cc == "" || $expire == "" ) { echo "Please insert full credit card details"; } else { function luhnCheck($cardNo) { $cardNo = str_replace(" ", "", trim($cardNo)); if(!is_numeric($cardNo) or strlen($cardNo)>19) return false; $skip = $newNum = $total = 0; for($i=0;$i<=(strlen($cardNo)-1);$i++) { if($skip ==0) { $tmpNum = ($cardNo[$i]*2); $total += (strlen($tmpNum)==2 ? (substr($tmpNum, 0, 1)+substr($tmpNum, 1)) : $tmpNum); $skip = 1; }else{ $total += $cardNo[$i]; $skip = 0; } } return (($total % 10) == 0); } /* Example Usage */ if(luhnCheck) { $updatebooking=mysql_query("UPDATE booking SET status='completed' WHERE users_id='$users_id' AND date='$bookeddate' AND time='$bookedtime' AND status='pending'"); $select=mysql_query("SELECT * FROM booking WHERE ride_id='1' AND users_id='$users_id' AND seat_no='$bookedseat' AND status='completed'"); while($row=mysql_fetch_array($select)) { $donetime=$row['time']; $donedate=$row['date']; $doneseat=$row['seat_no']; } $to = $email; $subject = "Your Ticket"; $headers = "From: mina@minashirazi.com"; $body = "Hello $username,\n\n <table> Please find the tickets you have booked. <td>Swinging For Seat: $doneseat on $donedate at $donetime</td> </table>"; } else { echo"There was an error updating your details"; } // echo("Valid Number."); //}else{ // echo("Invalid Number."); } } ?> <html> <head> </head> <body> <form name="confirm" method="post" action=""> <p> First Name:<br /> <input type="text" name='firstname' value="<? echo "$myfirstname";?>"> <p> Last Name:<br /> <input type="text" name='lastname' value="<? echo "$mylastname";?>"> <p> Email:<br /> <input type="text" name='email' value="<? echo "$myemail";?>"> <p> Net Price :<br /> <? echo "$rideprice"; ?> pounds<p> VAT :<br /> <? echo "$vat"; ?> pounds<p> Total :<br /> <? echo "$finalprice"; ?> pounds<p> Card No:<br/> <input type="text" name="cardNo"> <p>CCV:<br/> <input type="text" name="cc"> <p>Expiry Date<br/> <input type="text" name="expire" value="e.g 12/10"> <p> <input type="submit" name="pay" value="Pay Now"> </form> </body> Hi, I just cannot seem to get this to work, have been testing and searching all morning and not getting anywhere. I have a form with a series of checkboxes which populates the MySqL database, this works fine. Trying to print the results from the form if the row is empty show an unchecked checkbox, if there is a value show a checked checkbox. I have tested my if statement and can echo correctly wether empty or not empty, just cannot get the checkbox to be unticked if there is no value in the row Code: [Select] while ($row = mysql_fetch_array($qry, MYSQL_BOTH)) { // show total fields for debugging // $totalfields = mysql_num_fields($qry); // print ($totalfields) ; // if ( ! empty ( $row ['acid_wash'] ['neutralise'] ['clean'] ) ) { if ( ! empty ( $row ['clean'] ) ) { ///if it's 1 (true) then we add 'checked' to a variable we will use in the input //to cause it to be checked $checked = 'checked'; // test if row has data echo "full"; }else{ //if the value is 0 (false) we set the variable to be empty, not checked $checked = ''; // test for no value echo "empty" ; } To Display Result: <tr> <td>High Pressure Clean <input style='font-size:10px;' name='clean[]' type='checkbox' checked='$checked'></td> </tr> The empty and full test echos do seem to work, showing me the if statement works. The problem is even when the row is empty the checkbox shows checked.... Thanks. 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" > Hey guys, how do I send checkbox variables to my e-mail address once a user has checked it on the html form. Here is my html form: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Form</title> <script type="text/javascript"> //email form validation function everif(str) { var at="@" var punct="." var lat=str.indexOf(at) var lstr=str.length var lpunct=str.indexOf(punct) if (str.indexOf(at)==-1){ alert("Valid email must be entered") return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ alert("Valid email must be entered") return false } if (str.indexOf(punct)==-1 || str.indexOf(punct)==0 || str.indexOf(punct)==lstr){ alert("Valid email must be entered") return false } if (str.indexOf(at,(lat+1))!=-1){ alert("Valid email must be entered") return false } if (str.substring(lat-1,lat)==punct || str.substring(lat+1,lat+2)==punct){ alert("Valid email must be entered") return false } if (str.indexOf(punct,(lat+2))==-1){ alert("Valid email must be entered") return false } if (str.indexOf(" ")!=-1){ alert("Valid email must be entered") return false } return true } function evalid(){ var emailID=document.contact_form.mail if (everif(emailID.value)==false){ emailID.focus() return false } //empty field validation var naam=document.contact_form.naam if ((naam.value==null)||(naam.value=="")){ alert("Fields marqued with * must be entered") naam.focus() return false } var telefoon=document.contact_form.telefoon if ((telefoon.value==null)||(telefoon.value=="")){ alert("Fields marqued with * must be entered") telefoon.focus() return false } var branche=document.contact_form.branche if ((branche.value==null)||(branche.value=="")){ alert("Fields marqued with * must be entered") branche.focus() return false } return true } </script> </head> <body> <form name="contact_form" method="post" id="contactform" action="doeactie.php" onSubmit="return evalid()"> <table border="0"> <tr> <td><label for="bedrijfsnaam">Company name</label></td> <td colspan="2"><input name="bedrijfsnaam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="naam">Name *</label></td> <td colspan="2"><input name="naam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="mail">E-mail *</label></td> <td colspan="2"><input type="text" name="mail" class="text" size="30" /></td> </tr><tr> <td><label for="adres">Address</label></td> <td colspan="2"><input name="adres" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="plaatsnaam">City</label></td> <td colspan="2"><input name="plaatsnaam" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="postcode">Zip</label></td> <td colspan="2"><input type="text" name="postcode" class="text" size="10" /></td> </tr><tr> <td><label for="branche">Niche *</label></td> <td colspan="2"><input name="branche" type="text" class="text" size="30" /></td> </tr><tr> <td><label for="telefoon">Phone *</label></td> <td colspan="2"><input name="telefoon" class="text" type="text" size="30" /></td> </tr><tr> <td><label for="bericht">Question or Comment</label></td> <td colspan="2"><textarea name="message" class="text" onkeyup="return limitarelungime(this, 255)" cols="35" rows="5"></textarea></td> </tr> </table> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td></td> <td height="25"></td> </tr> <tr> <td></td> <td height="30" valign="top"><font face="arial" size="2"><b>I would also like to receive information about :</b></font></td> </tr> <tr> <td><input type="checkbox" name="emailmarketing" id="emailmarketing" value="emailmarketing" /></td> <td height="25"><font face="arial" size="2">E-mail Campaign</font></td> </tr> <tr> <td><input type="checkbox" name="zoekmachopt" id="zoekmachopt" value="zoekmachopt" /></td> <td height="25"><font face="arial" size="2">SEO</font></td> </tr> <tr> <td><input type="checkbox" name="socialmedia" id="id" value="socialmedia" /></td> <td height="25"><font face="arial" size="2">Social Media</font></td> </tr> <tr> <td><input type="checkbox" name="videomarketing" id="videomarketing" value="videomarketing" /></td> <td height="25"><font face="arial" size="2">Video Marketing</font></td> </tr> <tr> <td><input type="checkbox" name="webshop" id="webshop" value="webshop" /></td> <td height="25"><font face="arial" size="2">Webshop</font></td> </tr> <tr> <td><input type="checkbox" name="cms" id="cms" value="cms" /></td> <td height="25"><font face="arial" size="2">Content Management System</font></td> </tr> <tr> <td><input type="checkbox" name="grafisch" id="grafisch" value="grafisch" /></td> <td height="25"><font face="arial" size="2">Graphic Design</font></td> </tr> <tr> <td></td> <td align="left"><br /><input type="submit" name="Submit" value="Send"></td> <td align="right"></td> </tr> </table> </form> </body> </html> and this is the PHP script that processes this. Everything works except for the checkbox part. <?php session_start(); if(isset($_POST['Submit'])) { $youremail = 'blabla@gmail.com'; $fromsubject = 'Request from form'; $bedrijfsnaam = $_POST['bedrijfsnaam']; $naam = $_POST['naam']; $mail = $_POST['mail']; $adres = $_POST['adres']; $plaatsnaam = $_POST['plaatsnaam']; $postcode = $_POST['postcode']; $branche = $_POST['branche']; $telefoon = $_POST['telefoon']; $message = $_POST['message']; $to = $youremail; $mailsubject = 'Bericht ontvangen van'.$fromsubject.' Actie Pagina'; $body = $fromsubject.' Bedrijfsnaam: '.$bedrijfsnaam.' Naam Contact Persoon: '.$naam.' E-mail: '.$mail.' Adres: '.$adres.' Plaatsnaam: '.$plaatsnaam.' Postcode: '.$postcode.' Branche: '.$branche.' Telefoonnummer: '.$telefoon.' vraag of Wens: '.$message.' |---------End Message----------|'; echo "thank you for your request we will contact you asap."; mail($to, $subject, $body); } else { echo "Error Please <a href='form.html'>try again</a>"; } ?> Any help would be great! Thanks guys <script type="text/javascript"> Hi I have a bit of code here and I can not get it to work right!!! It is a contact form from a website and the error i get is; Warning: implode() [function.implode]: Invalid arguments passed in /home/leveldte/public_html/contact-send.php on line 61 I have got no idar what to do. <?php function validateForm($data) { $errors = array(); if(empty($data['name'])) { $errors['name'] = '<p class="error">You must complete the name field</p>'; } elseif(!preg_match('/[-a-z\'` ]+/i', $data['name'])) { $errors['name'] = '<p class="error">The name you entered is not valid</p>'; } if(empty($data['email'])) { $errors['email'] = '<p class="error">You must complete the email field</p>'; } elseif(!filter_var($data['email'], FILTER_VALIDATE_EMAIL)) { $errors['email'] = '<p class="error">The email address you entered is not valid</p>'; } if(empty($data['message'])) { $errors['message'] = '<p class="error">You must enter a message</p>'; } return $errors; } function processTheForm($to) { $result = array(); if($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST['middle-name'])) { $errors = validateForm($_POST); $_POST['message'] = strip_tags($_POST['message']); $subject= strip_tags($_POST['subject']); if(empty($subject)) { $subject = 'Message from '.$_POST['name']; } if(empty($errors)) { $headers = array( 'Content-type'=>'text/html', 'From'=>"{$_POST['name']}<{$_POST['email']}>", 'To'=>$to, 'Date'=>date('r') ); $mailTpl = file_get_contents('mail-template.tpl.php'); $mailTpl = str_replace(array('[name]', '[email]', '[message]'), array($_POST['name'], $_POST['email'], $_POST['message']), $mailTpl); if(mail($to, $subject, $mailTpl, implode("\r\n", $headders))) { unset($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message']); $result['mail_error'] = false; } else { $result['mail_error'] = true; } } $result['errors'] = $errors; } return $result; } Thanks for your help everyone! Daniel 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 well i got a few checbox (look below for code) i want to make it so that if i click the checkbox's it sends all the check box value to one column with "," in between them Code: [Select] <input type="checkbox" name="genre" value="fighting" id="genre"/>fighting <input type="checkbox" name="genre" value="school life" id="genre" />school life <input name="genre" type="checkbox" id="genre" value="king" id="genre" />king <input name="genre" type="checkbox" id="genre" value="him" />him Hello i have some problems i hope some one can help me, first i want add new field data for like (data number) but if i add $name=$_POST['NR']; and make new <td><div align="left">Your number</div></td> <td><input name="NR" type="text" size="40"></td> and $query=( "INSERT INTO user (uname, pw,email,NR,date_joined,ip,level) VALUES ('$name',password('$pw1'),'$email',NOW(),'$ip','Normal')"); i get no result to database what could be the problem (database table exsist) Code: [Select] <?php if(isset($_POST['Submit'])){ //NEED TO CHECK IF FIELDS ARE FILLED IN if( empty($_POST['name']) && (empty($_POST['email']))){ header("Location:Messages.php?msg=3"); exit(); } if( empty($_POST['pw1']) && (empty($_POST['pw2']))){ header( "Location:Messages.php?msg=4" ); exit(); } $name=$_POST['name']; $email=$_POST['email']; $pw1=$_POST['pw1']; $pw2=$_POST['pw2']; if("$pw1" !== "$pw2" ){ header( "Location:Messages.php?msg=5" ); exit(); } $ip = $_SERVER['REMOTE_ADDR']; //connect to the db server , check if uname exist include('config.php'); $query=("Select * from user where uname='$name'"); $result= mysql_query($query); $num=mysql_num_rows($result); if ($num > 0) {//Username already exist header( "Location:Messages.php?msg=6" ); exit(); }else{ //if username does not exist insert user details $query=( "INSERT INTO user (uname, pw,email,date_joined,ip,level) VALUES ('$name',password('$pw1'),'$email',NOW(),'$ip','Normal')"); if (@mysql_query ($query)) { header("location:login.php?reg=1"); exit; } } mysql_close(); } ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><!-- InstanceBegin template="/Templates/Auth.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <!-- InstanceBeginEditable name="doctitle" --> <title>Registration</title> <!-- InstanceEndEditable --> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> <link href="styleLog.css" rel="stylesheet" type="text/css"> </head> <body> <table width="100%" border="0" cellspacing="7" cellpadding="0"> <tr class="temptitle"> <td><!-- InstanceBeginEditable name="EditRegion4" -->New User Registration <!-- InstanceEndEditable --></td> </tr> <tr> <td><!-- InstanceBeginEditable name="EditRegion3" --> <form name="form1" action="register.php" method="post"> <table width="657" border="0"> <tr> <td width="122"><div align="left">Name</div></td> <td width="525"><input name="name" type="text" size="40"></td> </tr> <tr> <td><div align="left">Email</div></td> <td><input name="email" type="text" size="40"></td> </tr> <tr> <td><div align="left">Password</div></td> <td><input name="pw1" type="password" size="40"></td> </tr> <tr> <td ><div align="left">Confirm Password </div></td> <td><input name="pw2" type="password" size="40"></td> </tr> <tr> <td></td> <td> <input name="Submit" type="submit"></td> </tr> </table> </form> <!-- InstanceEndEditable --></td> </tr> <tr> <td><div align="center">Copyright 2005 </div></td> </tr> </table> </body> <!-- InstanceEnd --></html> Hi guys please i need your help . i created a HTML/PHP form . The PHP form handles posting to my mail while the HTML is the front face / webpage . Anyway i created a form that has fields such as name (textbox), email(textbox) , inquiry(textarea) , state (textbox) country (dropdown list ) , how did you find us (dropdown list). However whenever i test the form all it posts to my mailbox is name , email , inquiry . Please how do i make the other fields get recognized / how do i get the details in the other fields to be posted to my mailbox. I am getting an error message. But the program works Code: [Select] Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\Exam_Online\try.php:3) in C:\xampp\htdocs\Exam_Online\Staff_login_process.php on line 4 Wrong Username or Password my code is <Html> <?php //session_start(); include 'Staff_login_process.php'; MYSQL_CONNECT(localhost,'root','') OR DIE("Unable to connect to database"); @mysql_select_db(Examination) or die( "Unable to select database"); ?> <body> <form action="try1.php" method="post"> <?PHP $query=("SELECT * FROM User u, User_X_Subject us, Subject s WHERE u.Use_Name = '{$_SESSION['username']}' AND u.Use_ID= us.Use_ID AND s.Sub_ID=us.Sub_ID"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); echo "<select name=myselect>"; while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['Sub_ID'].">".$row['Sub_Name']."</OPTION>"; } echo "</select>"; ?> <input type="submit" value="submit"/> </form> </body> </html> Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/hedgehog/public_html/class/class.phpmailer.php:3005) in /home/hedgehog/public_html/admin/class/authenticate.class.php on line 15 I own a website, www.gpstudios.com Some time ago I started recieiving this error after posting comments on the playgame page/news page. Try posting comments yourself on this game: http://www.gpstudios.com/playgame.php?gameid=324 I have attached a picture of the error. Unfortunately, I have no idea when this bug appeared. It must have happened a while ago, but I never noticed. Anyone know how or why I am getting this bug? Because I'm unsure as to where/when the error occurred, I cannot supply the code. Sorry for the lack of details, but I'm hoping someone will understand this error a little better than me :S Thanks, -Tom My login script wont take my users to the restricted page and im not quite sure why it must be the header because it echos"wrong username or password" when i put in the wrong username or password here is my code: if($count==1 & $row['flight']=="vulcan"){ session_start(vmyusername); session_start(vmypassword); header("location:/vulcan/index.php"); }else if($count==1 & $row['flight']=="valiant"){ session_start(myusernamev); session_start(mypasswordv); header("location:valiant/index.php"); }else { echo "Wrong Username or Password"; } } ?> Any help would be much appriciated Thanks, Blink359 Hi guys, I was wondering if it is possible to like a page on facebook through a checkbox, instead of using the FB like function/script. In other words; people fill out a form and can check the box if they like the page, such as: Code: [Select] <?php if (isset($_POST['form'])) { if (isset($_POST['facebook_checkbox'])) { //like page } else{ //don't like } } ?> <form action="<? $_SERVER['PHP_SELF'];?>" method="post"> <input type="checkbox" id="facebook_checkbox" name="facebook_checkbox" /> <input type="submit" name="form" /> Is there any possibility to do that? Thanks in advance. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=318598.0 I have a problem, i have page to send via mail function, cant snd html page, when recive mail, there is no layout, but text is there, also there are no images, and i put full address to image file. Using content type html/text, and still nothing :-( Can someone help me? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=320495.0 I have a small family only website and I use this code on my login page to see if members are having trouble re logging in.
// routine writes to file when this page is accessed
<?php $logfile = '/home/xxxxxxx/public_html/temp/trouble.txt'; $date = date('j M Y H:i:s'); if (isset($_COOKIE["family_user"])) { $user = $_COOKIE["family_user"]; } if ($file = @fopen($logfile, 'a')) { fwrite($file, "\r\n$date $user "); fclose($file); } ?> How can I use the information gathered (fwrite($file, "\r\n$date $user ") that writes to my trouble.txt file be sent to me via email. And ideally only once per session. I found this code will send me an email every time the page is accessed but can not figure out how to get fwrite($file, "\r\n$date $user " into either the subject (preferred) or into the body. <?php mail('yourEmailAddress@yourDomain.com','Subject of the e-mail','This is the body of the e-mail!'); ?> Anyone able to help with the code Thank you for your time |