PHP - Checkbox Button Not Working Properly
I'm trying to use checkbox to choose multiple data and submit(button 'Send SMS') them and direct them to another page, which will send text SMS to the numbers chosen. But when I try to click on one checkbox, it automatically directs me to the next page, without having to click on the 'Send SMS' button. I tried to see which part is the problem, but I can't determine which one is wrong. Please help! Thank you.
<script type="text/javascript"> function checkedAll (frm1) {var aa= document.getElementById('frm1'); if (checked == false) { checked = true } else { checked = false }for (var i =0; i < aa.elements.length; i++){ aa.elements[i].checked = checked;} } </script> <TABLE width="1106" border="1" align="center" cellpadding="5" cellspacing="2" > <tr> <td colspan="9"> <form id ="frm1" action="sms_latecomers.php"> <input type='checkbox' name='checkall' onclick='checkedAll(frm1);' value=""> <input type="submit" name="Submit" id="button" value="SMS Reminder" style="background:#FFCC33"/> </td> </tr> <TR bgcolor="#996699"> <?php $count=0; ?> <TH width="32"></TH> <TH width="37"> <span class="style1"> <div align="center">No. </div></span></TH> <th width="101"><span class="style1">SUPERVISOR ID</span></th> <th width="101"><span class="style1">EMPLOYEE ID</span></th> <th width="153"><span class="style1">EMPLOYEE NAME</span></th> <th width="124"><span class="style1">DATE</span></th> <th width="153"><span class="style1">LATE CHECK IN</span></th> </TR> <?php while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { ?> <TR> <TD><input type="checkbox" name="chk1" value="<?php echo $row['supervisor_telno']; ?>" onClick="window.open('sms_latecomers.php?employee_id=<?php echo $row['employee_id']; ?>&supervisor_telno=<?php echo $row['supervisor_telno']; ?>');"></TD> <TD height="66">[bad html removed]<input type="checkbox" name="chk1" >--> <?php $count=$count+1; print($count);?></TD> <TD><div align="center"><?php echo $row['supervisor_id']; ?></div></TD> <TD><div align="center"><?php echo $row['employee_id']; ?></div></TD> <TD><div align="center"><?php echo $row['employee_name']; ?></div></TD> <TD><div align="center"><?php echo $row['DATE']; ?></div></TD> <TD><div align="center"><?php echo $row['TIME']; ?></div></TD> </TR> <?php } ?>[bad html removed]</form>--> </TABLE> Similar TutorialsI need bit of help, so I am looking into a plugin created for newsletter where default is it shows ad but it has option to remove ads by checking the check box. Default is to send ads in newsletter but if you don't want to send ads through newsletter then check the box. The problem is, it seems like checkbox selected is not being picked up. Some help would be appreciated. The custom field in wp:
'label' => 'Hide newsletter ads', 'name' => 'hide_ads', 'type' => 'checkbox', 'instructions' => 'Checking the checkbox will remove ads', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array( 'width' => '', 'class' => '', 'id' => '', ), 'choices' => array( 'Hide newsletter ads' => 'Hide newsletter ads', ), 'allow_custom' => 0, 'default_value' => array( ), 'layout' => 'block', 'toggle' => 0, 'return_format' => 'value', 'save_custom' => 0, ),
This is the php code for it: <!doctype html> <html lang="en-GB"> <head> <meta name="viewport" content="width=device-width" /> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <meta name="x-apple-disable-message-reformatting"> <title><?php the_title(); ?></title> <style> <?php require ABSPATH . 'path/newsletter.css'; ?> </style> <!--[if mso]> <style type="text/css"> .outlook-fallback-font { font-family: 'Lucida Bright', 'Cambria', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif; } </style> <![endif]--> </head> <?php $hide_newsletter_ads = get_field('hide_ads'); echo $hide_newsletter_ads; ?> <body itemscope itemtype="http://schema.org/EmailMessage"> <div class="wrap"> <?php if (!$hide_newsletter_ads) { include ABSPATH . 'path/ad-banner.php'; } ?> <div class="header"> <a href="<?php bloginfo( 'url' ); ?>"> <img src="<?php echo get_home_url().'logo.png' ?>" alt="News" /> </a> </div> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <?php if ( get_field( 'newsletter_summary' ) ) { ?> <div class="newsletter-summary"><?php the_field( 'newsletter_summary' ); ?></div> <?php } ?> <?php if ( have_rows( 'newsletter_content' ) ) : ?> <?php // Loop through the ACF blocks $count = 0; while ( have_rows( 'newsletter_content' ) ) : the_row(); if ( get_row_layout() === 'story' ) : ?> <?php if ( 0 === $count ) { ?> <span class="date outlook-fallback-font"><?php the_time( 'd M Y' ); ?></span> <?php } ?> <?php if ( get_sub_field( 'story_heading' ) ) : ?> <h1><?php the_sub_field( 'story_heading' ); ?></h1> <?php endif; ?> <div class="content"> <?php the_sub_field( 'story_content' ); ?> </div> <?php endif; if ( 'post_list' === get_row_layout() ) : ?> <?php $posts = get_sub_field( 'post_list' ); if ( $posts ) : ?> </div> <div class="story-list"> <h2><span class="wrap"><?php the_sub_field( 'post_list_heading' ); ?></span></h2> <div class="wrap-table"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <?php // Output story cards foreach ( $posts as $i => $post ) { if ( 0 === $i % 2 ) { echo '<tr>'; } $class = ( 0 === $i % 2 ) ? 'odd' : 'even'; $image_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), array( 640, 345 ) ); $image_srcset = wp_get_attachment_image_srcset( get_post_thumbnail_id( $post->ID ) ); echo sprintf( '<td class="story-cell %4$s" valign="top"> <a href="%1$s" class="story-card outlook-fallback-font"> <img src="%3$s" alt="" height="120" style="height: 150px; object-fit: cover;" /> <span>%2$s</span> </a> </td>', esc_url( get_permalink( $post->ID ) . '?utm_source=newsletter&utm_medium=email&utm_campaign=newsletter' ), // permalink esc_html( get_the_title( $post->ID ) ), // title // esc_attr( $image_src[0] ), // image - src esc_attr( $image_src[0] ), // image - src esc_attr( $class ) // class ); if ( 0 !== $i % 2 || count( $posts ) === ( $i + 1 ) ) { echo '</tr>'; } } ?> </table> </div> </div> <div class="wrap"> <?php endif; endif; if (!$hide_newsletter_ads) { (0 === $count) { include ABSPATH . 'path/mpu-1.php'; } if (1 === $count) { include ABSPATH . 'path/mpu-2.php'; } } $count++; endwhile; endif; ?> <div class="footer"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td align="left"> © <?php echo esc_html( date( 'Y' ) ); ?> </td> <td class="footer-link"> <a href="<?php echo get_permalink( get_page_by_path( 'privacy-policy' ) ); ?>">Privacy Policy</a> · <a href="%unsubscribe_url%">Unsubscribe</a> </td> </tr> </table> </div> </div> <?php endwhile; endif; ?>
Hi guys, I have stuck with this issue for over 3 hours now. My remove all button just wouldn't work.
Can anyone tell me what's the issue? I have 2 pages, one parent and another pop-up page that takes the values (cartSubmit) from parent. And I wrote out the code for both pages but I just cannot get it to work.
I apologize in advanced if my code looks messy or doesn't make any sense.
Please take a look at the code and let me know if you could spot anything wrong with it. Any help is greatly appreciated.
Here is the code related to the remove all button in the parent page:
if(isset($_POST['finalSelected'])) { echo "<br/>inside"; if(!empty($_POST['fSelected'])) { echo "<br/>if NOT empty"; $chosen = $_POST['fSelected']; foreach ($chosen as $item) echo "</br>aID selected: $item </br>"; //implode function to transform an array to a string //chosen(array) to $delimit(String) $delimitStr = implode(", ", $chosen); //Save the selected String to SESSION if(!isset($_SESSION["final"])) { $_SESSION["final"] .= "$delimitStr"; } else { $_SESSION["final"] .= ", $delimitStr"; } //Explode function to transform the SESSION variable back to an array for further trimming. $arraySession = explode(', ', $_SESSION["final"]); //Array unique to filter out duplicates. $uniqueArray = array_unique($arraySession); $cartSubmit = implode(", ",$uniqueArray); $_SESSION['cartSubmit'] = $cartSubmit; } else { echo "<br/>else empty"; $noSubmit = $_SESSION["final"]; //Explode function to transform the SESSION variable back to an array for further trimming. $arraySession = explode(', ', $_SESSION["final"]); //Array unique to filter out duplicates. $uniqueArray = array_unique($arraySession); $cartSubmit = implode(", ",$uniqueArray); $_SESSION['cartSubmit'] = $cartSubmit; } } <form name= "finalForm" method="POST" action="test6-1.php" target = "_self"> <input type="Submit" name="finalSelected"/> <a href="javascript:popup('test6-3.php?aID= <?php if(empty($_SESSION['final']) && empty($_SESSION['cartSubmit'])) echo "0"; else if(empty($cartSubmit)) echo "0"; else echo $_SESSION['cartSubmit'];?>')">Cart</a> <?php if(isset($FinalName)) { foreach($FinalName as $key => $item) {?> <tr><td> <input type="checkbox" name="fSelected[]" value="<?php echo htmlspecialchars($FinalID[$key])?>" /> <?php echo "$FinalID[$key] & $item";?> </td></tr> <?php } }?> </form>And here is the code in the pop-up page. <script> window.onunload = refreshParent; function refreshParent() { window.opener.location.reload(); } </script> if(isset($_POST['removeAll'])) { $aID = "0"; unset($_SESSION['cartSubmit']); unset($_SESSION['final']); header("Location : test6-3.php?aID=0"); } Edited by Cyjm1120, 18 November 2014 - 12:16 PM. This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=315457.0 Okay, so I am trying to make a play.php file connected to my database, this database got a table named "webclientcreate". When I go to play.php?id=1, it is showing the proper one (the 1st row wich got id 1 in it), however if I after that go to something random like play.php?fsfasd the ID 1s page still pops up.. I can also go to play.php?id=2 and still get the id 1's data. I want to make it that every row got its own information (well it does, but the php file doesnt seem to recieve it correctly). PHP version: 5.2.17 MySQL version: 5.1 Heres a picture of my table rows: I've censored the MySQL connection information, I know it is working properly. Code: [Select] <?php $connect = mysql_connect("mysql12.000webhost.com","****","******") or die(mysql_error()); mysql_select_db("***") or die(mysql_error()); $extract = mysql_query("SELECT * FROM webclientcreate"); $numrows = mysql_num_rows($extract); while ($row = mysql_fetch_assoc($extract)) { $id = $row['id']; $server = $row['name']; $ip = $row['ip']; $port = $row['port']; $background = $row['background']; } if (isset($ip)&&isset($port)&&!empty($ip)&&!empty($port)) { if (! $sock = @fsockopen($ip, $port, $num, $error, 1)) echo ""; else{ echo "<img src='fs/newyear/online.png'/>$ip on port $port is currently<B><FONT COLOR=lime> Online</b></FONT>"; fclose($sock); } } ?> <title>Playing <?php echo $server; ?> - ID <?php echo $id; ?> </title> <center> <body bgcolor="#000000"> <applet name=client width=765 height=503 archive='<?php echo $jars; ?>' code='client.class'> <PARAM name='java_arguments' value='-Xmx700m'> <PARAM name='server_name' value='<?php echo $server; ?>'> <PARAM name='detail' value='low'> <PARAM name='ip' value='<?php echo $ip; ?>'> <PARAM name='port' value='<?php echo $port; ?>'> <PARAM name='background_image' value='<?php echo $background; ?>'> <PARAM name='headicons' value=''> </applet> </center> Hi there, I have created an email script and i want it to email a different email depending on the subject chosen by raido boxes however the if's aren't doing what they should, If i select say recruitement it choses the last option and has the wrong subject here is my code: <html> <head> </head> <body> <form action="contact.php" method="post"> <fieldset> <legend>Contact Us</legend> Your Email:*<br> <input type="text" name="email"><br> Subject:*<br> Recruitment Enquiry:<input type="radio" name="subject" value="Recruitment"> Absense Notification:<input type="radio" name="subject" value="Absense"> General Enquiry<input type="radio" name="subject" value="Enquiry"> <br> Message:*<br> <textarea name="message" cols="50" rows="5"></textarea><br> <input type="submit" value="Send Email"> </form> Required fields are marked with a *<br><br> <?php if(isset($_POST)) { $email = $_POST['email']; $subject = $_POST['subject']; $message = $_POST['message']; //checcking that all relevent information is entered and correct if(!$email || !$message) { $errmessage ="Please fill in all required fields."; } if($subject="Recruitment") { $to="email1"; } if($subject="Notification") { $to="email2k"; } if($subject="Enquiry") { $to="email3"; } //Sending the email if nothing is wrong if(!$errmessage) { header("location:send.php?to=".$to."&subject=".$subject."&email=".$email."&message=".$message.""); }else{ echo $errmessage; } } ?> </body> </html> If anyone can help it would be greatly appriciated Thanks, blink359 Okay, the following php form is "somewhat" working. .I am not receiving all of the variables to my inbox.
This is the current form that i'm working on.
http://www.rodriguez...cr/schedule.php
The following fields are the ones are not passing through.
The Drop Down Menu: am, pm, the all day
Video
Case Option:
Additional Requests:
Firm Physical Address:
Fax No:
Here is the code
<?php function displayRequired($fieldName) { echo " \".$fieldName\"is required.<br />n"; } function validateInput($data, $fieldName){ global $errorCount; if (empty($data)){ displayRequired($fieldName); ++$errorCount; $retval = ""; } else { $retval = trim($data); $retval = stripslashes($retval); } return ($retval); } $Deposition = validateInput(safe($_POST['deposition']), "Deposition"); $Time = validateInput(safe($_POST['time']), "Time"); $Delivery = validateInput(safe($_POST['delivery']), "Delivery"); $Witness = validateInput(safe($_POST['witness']), "Witness"); $Location = validateInput(safe($_POST['location']), "Location"); $Attorney = validateInput(safe($_POST['attorney']), "Attorney"); $Name = validateInput(safe($_POST['name']), "First Name"); $Firm = validateInput(safe($_POST['firm']), "Firm Name"); $Phone = validateInput(safe($_POST['phone']), "Phone"); $Email = validateInput(safe($_POST['email']), "Email"); if ($errorCount>0){ echo "Please re-enter the information below.<br />\n"; redisplayForm($Deposition, $Time , $Ampm, $Timeday, $Delivery, $Video, $Co1, $Co2, $Witness, $Location, $Additional, $Attorney, $Name, $Firm, $Address, $Phone, $Fax, $Email); } else { $To = "service@rodriguezstudios.com"; $Subject = "The test"; $From = "Schedule a Deposition - Professional Court Reporters"; $Message .= "Deposition Date: " . $Deposition . "\n"; $Message .= "Time: " . $Time . $Ampm. $Timeday . "\n\n"; $Message .= "Transcript Delivery: " . $Delivery . "\n\n\n"; $Message .= "Video: " . $Video . "\n\n\n\n"; $Message .= "Case Option: " . $Co1. "vs: " . $Co2 . "\n\n\n\n\n"; $Message .= "Witness: " . $Witness . "\n\n\n\n\n\n"; $Message .= "Location: " . $Location . "\n\n\n\n\n\n\n"; $Message .= "Additional Requests: " . $Additional. "\n\n\n\n\n\n\n\n"; $Message .= "Attorney Name: " . $Attorney . "\n\n\n\n\n\n\n\n\n"; $Message .= "Your Name: " . $Name . "\n\n\n\n\n\n\n\n\n\n"; $Message .= "Firm Name: " . $Firm. "\n\n\n\n\n\n\n\n\n\n\n"; $Message .= "Firm Physical Address: " . $Address . "\n\n\n\n\n\n\n\n\n\n\n\n"; $Message .= "Phone No: " . $Phone . "\n\n\n\n\n\n\n\n\n\n\n\n\n"; $Message .= "Fax No: " . $Fax. "\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; $Message .= "Email: " . $Email . "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"; $Headers = "From: ". $From . "<" . $To. ">\r\n"; $Headers .= "Reply-To: " . $Email . "\r\n"; $Headers .= "Return-path: ". $Email; $result = mail($To, $Subject, $Message, $Headers); if ($result) $resultMsg = "You message was sucessfully sent."; else $resultMsg = "There was a problem sending your message."; /*insert anti spam fragement here */ ?> <p style="line-height:200%; text-align:center; font-family:Verdana, Geneva, sans-serif; color:#000000">Your deposition has been scheduled<?php if(!empty($fieldName)) { echo " , {$fieldName}. {$resultMsg}"; } echo "</p>"; } ?> <?php function redisplayForm($Deposition, $Time , $Ampm, $Timeday, $Delivery, $Video, $Co1, $Co2, $Witness, $Location, $Additional, $Attorney, $Name, $Firm, $Address, $Phone, $Fax, $Email){ ?> <form action="" method="POST"> <fieldset class="first"> <fieldset class="first"> <p> <label class="labelone"for="deposition">*Deposition Date:</label> <input type="text" id="datepicker" name="deposition" value="<?php echo $Deposition; ?>" /> </p> <p> <label for="*Time:" name="time">*Time: </label> <input type="text" name="time" value="<?php echo $Time; ?>"> <select name="ampm" id="Ampm"> <option value="am">A.M.</option> <option value="pm">P.M.</option> </select> <select name="timeday" id="Timeday"> <option value="all">All Day</option> <option value="half">Half Day</option> <option value="hours">1-2 hrs</option> </select> </p> <p> <label for="*Transcript Delivery:" name="transcript"/> *Transcript Delivery:</label> <select> <option value="regular">Regular Delivery (10 day)</option> <option value="same">Same Day</option> <option value="1day">1 Day</option> <option value="2day">2 Day</option> <option value="3day">3 Day</option> <option value="4day">4 Day</option> <option value="5day">5 Day</option> </select> </p> <p> <label for="*Video" name="video">*Video:</label> <select name="video" id="video"> <option value="yes">Yes</option> <option value="no">No</option> </select> </label> </p> <p> <label for ="caseoption">Case Option:</label> <input type="text" name="co1" value="<?php echo $Co1; ?>"/> vs. <input type="text" name="co2" value="<?php echo $Co2; ?>" /> </p> <p> <label for ="witness">*Witness:</label> <input type="text" name="witness" value="<?php echo $Witness; ?>" /> </p> </fieldset> <fieldset> <legend>LOCATION OF DEPOSITION, TELEPHONE NUMBER, AND NAME OF CONTACT PERSON:</legend> <p> <label for="location">*Location:</label> <textarea name="location" id="Location" value="<?php echo $Location; ?>"></textarea> </p> <p> <label for="additional">Addtional Requests (i.e. Realtime):</label> <input type="text" name="additional" value="<?php echo $Additional; ?>" /> </p> <p> <label for ="attorney">*Attorney Name:</label> <input type="text" name="attorney" value="<?php echo $Attorney; ?>" /> <p> <label for ="name">*Your Name:</label> <input type="text" name="name" value="<?php echo $Name; ?>" /> </p> <label for ="firm">*Firm Name:</label> <input type="text" name="firm" value="<?php echo $Firm; ?>" /> </p> <p> <label for ="firmaddress">Firm's Physical Address:</label> <input type="text" name="address" value="<?php echo $Address; ?>" /> </p> <p> <label for ="phone">*Phone No:</label> <input type="text" name="phone" value="<?php echo $Phone; ?>"/> </p> <p> <label for ="fax">Fax No:</label> <input type="text" name="fax" value="<?php echo $Fax; ?>"/> </p> <p> <label for ="email">*Email:</label> <input type="text" name="email" value="<?php echo $Email; ?>" /> </p> </fieldset> <fieldset> <input class="btn" name="submit" type="submit" value="Send Email"/> <input class="btn" name="reset" type="reset" value="Clear Form" /> </fieldset> </form> <?php } ?> <?php function safe($string) { $pattern = "/\r|\n|\%0a|\%0d|Content\-Type:|bcc:|to:|cc:/i"; return preg_replace($pattern, '', $string); } ?>The extra pair of eyes would be greatly appreciated! hello.. In this script. if part is working properly. but elseif part not working i expect. it display only 1 category and its subjects. Anybody can tell me what the mistake that I have did... Here is my script Code: [Select] } elseif ( isset($_POST['category']) && ( sizeof( $_POST['category']) == 2 || sizeof( $_POST['category']) == 3 )) { $q = 'SELECT * FROM category ORDER BY category_id'; $r = mysqli_query( $dbc, $q); while($row = mysqli_fetch_array( $r, MYSQLI_ASSOC )) { foreach( $category as $value ) { if ( $value == $row['category_id']) { echo '<input type="radio" name="category[]" value="' . $row['category_id'] . '" class="radio" />'; echo '<label for="" class="radio"> ' . $row['category_name'] . ' <strong>: Mark this category as my "Main Category"</strong></label><br />'; $q = "SELECT category_subject.category_id, category_subject.subject_id, subjects FROM category_subject INNER JOIN category ON category_subject.category_id = category.category_id INNER JOIN subject ON category_subject.subject_id = subject.subject_id WHERE category_subject.category_id = {$row['category_id']}"; $r = mysqli_query( $dbc, $q); $c = $i = 0; echo '<table class="form_table" ><tr>'; while($info = mysqli_fetch_array( $r, MYSQLI_ASSOC )){ // if remainder is zero after 2 iterations (for 2 columns) and when $c > 0, end row and start a new row: if( ($c % 2) == 0 && $c != 0){ echo "</tr><tr>"; } echo '<td width="50%"><input type="checkbox" name="category[]" value="' . $info['subject_id'] . '" /> ' . $info['subjects'] . '</td>'; $c++; } // while.. // in case you need to fill a last empty cell: if ( ( $i % 2 ) != 0 ){ // str_repeat() will be handy when you want more than 2 columns echo str_repeat( "<td> </td>", ( 2 - ( $i % 2 ) ) ); } echo "</tr></table>"; } } } } Hi, I'm having problems with a PHP mail handler and everything seems to be working fine except I get slashes in the message body from the form. If my input is "Please don't delete this" I get "Please don/'t delete this" in the message body, however it is striping the other tags. I'm not sure what is wrong and was hoping for a bit of help to figure this out. Here is the code: Code: [Select] <?php $owner_email = $_POST["owner_email"]; $headers = 'From:' . $_POST["email"]; $subject = 'Website contact inquiry from ' . $_POST["name"]; $messageBody = ""; $messageBody .= '<p>------------------ Contact Details ------------------' . '</p>' . "\n"; $messageBody .= '<p>Name: ' . $_POST["name"] . '</p>' . "\n"; $messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n"; $messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n"; $messageBody .= '<p>----------------------------------------------------------' . '</p>' . "\n"; $messageBody .= '<br>' . "\n"; $messageBody .= '<p>' . $_POST['message'] . '</p>' . "\n"; if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } ?> Why is my code below not working properly? I've tried it with == instead of = and it still doesn't work. I've verified using echo statements that $row['name'] = $_POST['name'] and $row['password'] = $_POST['password'] for one of the people in my database, but it still gives the message "Login or password wrong!" Thanks a lot for any help, here is the relevant part of my code (counterInt is defined to be 0 further up): while($row = mysql_fetch_array( $result )) { if($row['name'] = $_POST['name'] & $row['password'] = $_POST['password']) { $counterInt++; session_start(); $_SESSION['name']=$row['name']; } } if(counterInt == 1) { header( 'Location: http://simbazeviangame.99k.org/game.php' ); } if(counterInt == 0) { echo "Login or password wrong!"; } This is the first time Im trying to use REGEXP, but cant get it working. It gives no error, just nothing..Anyone got idea why, please? Thanks <?php include ('connectToDatabase.php'); $getSearch = $_REQUEST['getSearch']; $keywordSearchQuery = "SELECT shoeName, shoeSize, colour, price, gender, description WHERE shoeName REGEXP '.*($getSearch).*' || shoeSize REGEXP '.*($getSearch).*' || colour REGEXP '.*($getSearch).*' || price REGEXP '.*($getSearch).*' || gender REGEXP '.*($getSearch).*' || description REGEXP '.*($getSearch).*" ; $keywordSearchQueryResult = mysql_query($keywordSearchQuery); echo "$keywordSearchQueryResult"; ?> I'm trying to do a string match of a "what is my browser" return
I counted the indexes, there are 30
I have this code, I tested four different browsers, Internet Explorer, Chrome, Chromium, Firefox
Only chromium works, why? I counted the indexes for both Firefox and Chromium output, they are identical unless I miscounted
I don't have internet explorer or chrome, I had a friend test pull up the link that has this code
<?php $browsee = get_browser(null,true); $array = (array_slice($browsee,5,-24)); if(in_array("Firefox",$array)){ echo "your browser is firefox"; }else if(in_array("Chromium",$array)){ echo "your browser is chromium"; }else if(in_array("Chrome",$array)){ echo "your browser is chrome"; }else if(in_array("Explorer",$array)){ echo "your browser is Internet Explorer"; }else{ echo "your browser was not detected"; } echo '<br>'; echo '<br>'; print_r($browsee); ?>These are screenshots of the two browsers I use (I'm a Linux user) chromium.png 125.92KB 0 downloads firefox.png 137.44KB 0 downloads Here's the code with the function that won't work! Code: [Select] $itemsRaw = explode(" ", $player['inventory']); foreach ($itemsRaw as $inv){ $contents = explode("-", $inv); if(strlen($contents[0]) > 0 && strlen($contents[1]) > 0 && $contents[1] > 0) echo getItemName($contents[0]) . " (" . number_format($contents[1]) . ")<br />"; } Here's my function: Code: [Select] function getItemName($id_raw){ $id = $id_raw - 1; $q = $db->query("SELECT * FROM items WHERE id = $id") or die(mysql_error()); $f = $db->fetch_assoc($q); return $f['name']; } It stops the page when it gets to that point and won't load anything else and the function doesn't even work with it :/ What's wrong with it? If anything.. Hi everyone, my contact us form and script isn't working how it should. On send the data is not sent to the db, a () is the ONLY thing shown in the browser too, can somebody help make this work? Heres the form: Code: [Select] <form method="get" action="contact-send.php"> Name:<br /> <input type="text" name="name" id="name" size="30" /><br /> Email:<br /> <input type="email" name="email" id="email" size="30" /><br /> Your Question:<br /> <textarea name="question" id="question" rows="10" cols="50"></textarea><br /> <input type="submit" name="submit" value="send" /> </form And the script to process: Code: [Select] <?PHP session_start(); include ('php only scripts/db.php'); if ($db_found) { $SQL = "INSERT INTO 'contact_us' (name, email, question) VALUES ('" .$name. "', '" .$email. "', '" .$question. "')"; $result = mysql_query($query) or die(mysql_error()); header( 'Location: http://www.removalspace.com/contactconf.php' ); } ?> Iv'e messed with it and had database NOT found before but since then, messed some more and before i go in circles i need some help :| Thanks in advance for any help! So, i need this. i have an html form which is a "post" on it i have an array of checkboxes and a sumbit button, once button is clicked i go to another page where i handle those boxes checked the problem now is if NO checkboxes are checked and i hit the submit...i get errors on the other page my code: foreach($product_names as $product_row) { ?> <tr> <td > </td><td width='200px'><?php echo $product_row->getName(); ?></td> <td width='200px'><input type="checkbox" name="graphic[]" value="<?php echo $product_row->getId();?>" /></td> <td width='200px'><input type="checkbox" name="text[]" value="<?php echo $product_row->getId();?>" /></td> </tr> <?php } ?> </table> <table> <tr> <td> <input type='submit' name='submit' value='Submit'> <?php if ( (isset($graphic)) || (isset($text) )) { echo "checkboxes checked"; //show submit button } else { //hide submit botton and echo "no boxes check"; } ?> the above is NOT working please help???? I have a dynamic script and need to create a click event function with JavaScript to delete the row which has a checkbox checked when the delete button is pressed. This is being implemented with PHP and as now serves as light code for this matter at hand. I was only able to delete all rows. I have my efforts with the js functions too. <script type="text/javascript"> var counter = 1; var limit = 6; function addTextArea() { if (counter == limit-1) { alert("Maximum limit " + counter + " sorry"); return false; } else { <!-- CAUTION THIS IS BACKWARDS. --> var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><textarea name='fav_det[]' id=counter rows='3' cols='20'>"; document.getElementById('div6').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><textarea name='fav_col' id=counter rows='3' cols='20'>"; document.getElementById('div5').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><textarea name='fav_mod[]' id=counter rows='3' cols='20'>"; document.getElementById('div4').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = " " + (counter + 1) + " <br><input type='text' name='truck[]' id=counter>"; document.getElementById('div3').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = " " + (counter + 1) + " <br><input type='text' name='car[]' id=counter>"; document.getElementById('div2').appendChild(newdiv); var newdiv = document.createElement('div'); newdiv.innerHTML = "" + (counter + 1) + " <br><input type='checkbox' name='chk[]' id=counter>"; document.getElementById('div1').appendChild(newdiv); counter++ return true; } } </script> <script type="text/javascript"> function deleteRowS(dataTable) { for (var rowi= table.rows.length; rowi-->0;) { var row= table.rows[rowi]; var inputs= row.getElementsByTagName('dataTable'); for (var inputi= inputs.length; inputi-->0;) { var input= inputs[inputi]; if (input.type==='checkbox' && input.checked) { row.parentNode.removeChild(row); break; } } } } </script> <script type="text/javascript"> function deleteRow() { var table = document.getElementById(tableID).tBodies[0]; var rowCount = table.rows.length; // var i=1 to start after header for(var i=1; i<rowCount; i++) { var row = table.rows[i]; // index of td contain checkbox is 8 var chkbox = row.cells[6].getElementsByTagName('input')[0]; if('checkbox' == chkbox.type && true == chkbox.checked) { table.deleteRow(i); } } }</script> </head> <table> <tr><td valign='top'><b>NEED DELETE ROW WITH CHECKBOX FUNCTION:</td></tr> </table> <table id="dataTable" width="auto" style="margin:-4px 0 0 0; padding:14px 0 0 0;" cellspacing="10px"><tbody id="dataTable"></tbody> <tr> <td valign='Top'> ✗ <div id="div1"> <input type="checkbox" name="chk[]" autocomplete="off" id="1" > </div> </td> <td valign='Top'> cars <div id="div2"> <input type="text" name="car[]" id="2" > </div> </td> <td valign='Top'> trucks <div id="div3"> <input type="text" name="truck[]" id="3" > </div> </td> <td valign='Top'> your favorite model <div id="div4"> <textarea name="mod[]" id="4" rows="3" cols="20"></textarea> </div> <br><br> </td> <td valign='Top'> your favorite add-ons <div id="div5"> <textarea name="fav_col" id="5" rows="3" cols="20"></textarea> </div> </td> <td valign='Top'> explain vehicle overall <div id="div6"> <textarea name="fav_det" id="6" rows="3" cols="20"></textarea> </div> </td> </tr> </table> <input type="button" value="Add another" onClick="addTextArea();" /> <input type="button" value="Delete row" onclick="deleteRow('dataTable');deleteRowS('dataTable')" /> Which languages do I need to make this happen? And I am unsure of how to incorporate PHP within a javascript query and what jQuery functions I will need. Hello everyone, Let me start by saying that this is my first post on this forum and that I am quite a noob when it comes to scripting. With that said, here is my problem: I am trying to edit a getID3 demo file properly to retrieve metadata from mp4 files. The code below belongs from the demo file. <?php require_once('../getid3/getid3.php'); $getID3 = new getID3; $DirectoryToScan = '../container'; $dir = opendir($DirectoryToScan); echo '<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="3">'; echo '<TR><TH>Filename</TH><TH>Artist</TH><TH>Title</TH><TH>Bitrate</TH><TH>Playtime</TH></TR>'; while (($file = readdir($dir)) !== false) { $FullFileName = realpath($DirectoryToScan.'/'.$file); if (is_file($FullFileName)) { set_time_limit(30); $ThisFileInfo = $getID3->analyze($FullFileName); getid3_lib::CopyTagsToComments($ThisFileInfo); echo '<TR>'; echo '<TD>'.$ThisFileInfo['filenamepath'].'</TD>'; echo '<TD>'.(!empty($ThisFileInfo['comments_html']['artist']) ? implode('<BR>', $ThisFileInfo['comments_html']['artist']) : ' ').'</TD>'; echo '<TD>'.(!empty($ThisFileInfo['comments_html']['title']) ? implode('<BR>', $ThisFileInfo['comments_html']['title']) : ' ').'</TD>'; echo '<TD ALIGN="RIGHT">'.(!empty($ThisFileInfo['audio']['bitrate']) ? round($ThisFileInfo['audio']['bitrate'] / 1000).' kbps' : ' ').'</TD>'; echo '<TD ALIGN="RIGHT">'.(!empty($ThisFileInfo['playtime_string']) ? $ThisFileInfo['playtime_string'] : ' ').'</TD>'; echo '</TR>'; } } ?> I have added 2 test files in 'container' for testing only. See this image for the result I am getting. As you can see the code isn't retrieving any data at all. Can anyone help me out with this? Thanks in advance, Melissa Okay im trying to make it so when some is on this link ("?serv=del&id=$ID") it displays a portlet of a yes/no form. onces yes/no is picked it goes to ("?serv=del&id=$ID&del=true"). I have no idea if im doing this right or if theres a better way of doing it. But trying to fix this problem has almost made me throw my computer threw my window. Thanks in advanced. <?php if(isset($_GET['serv']) && $_GET['id'] == $serverid && $_GET['del'] == 'true') { if($_POST['ture']) { mysql_query("DELETE FROM `notifications` WHERE `id`='$msgid'"); Echo "<center>Message Deleted</center>"; } else { Echo "<center>Message delete request has been canceled.</center>"; } } elseif(isset($_GET['serv']) && $_GET['id'] == $serverid) { ?> <div class="usercp_body"><!-- UserCP Notification Manage Start --> <div id="dash_chart" class="portlet" style="width:100%;margin: 0 auto;"> <div class="portlet-header"> <h4><center>All Servers For <?php echo $username; ?></center></h4> </div> <div class="portlet-content"> <form action="manage.php?serv=del&id=<?php echo $serverid; ?>&del=true" method="post"> <input type="submit" class="bgbtn blue" value="Yes" name="true" /> <input type="submit" class="bgbtn blue" value="No" name="false" /> </form> </div> </div> </div> <?php } ?> So ive created a forum that I got handling several different approvals. (it is used to approve or decline all submitted notes) it works fine and it even submits fine im at the part know where i process the information and do something with it, below is my form: <form action="course_proccess.php?action=approve" method="post"> <table align="left" border="1" cellspacing="0" cellpadding="3"> <tr> <td><b>Author</b></td> <td><b>File name</b></td> <td><b>Download</b></td> <td><b>Suggested catagory</b></td> <td><b>Select Catagory</b></td> <td>Approve</td> </tr> <td><input type="text " disabled="disabled" name="tr1_author" value="MikeH" </td> <td><input typee="text " disabled="disabled" name="tr1_name" value="A lot of my skills set back"</td> <td><a href= /uzEr%20Upl0ds/cache.zip > Download</a></td> <td>1001 Laws - Polceing </td> <td><select name="tr1_scatagory"> <option value="1"> Intro To Law </option> <option value="2"> 1001 Laws - Police Foundations </option> </select></td> <td><select name = "tr1_approve"> <option value = "1"> Yes</option> <option value = "2"> no</option> </select></td> </tr> <td><input type="text " disabled="disabled" name="tr2_author" value="MikeH" </td> <td><input typee="text " disabled="disabled" name="tr2_name" value="MM"</td> <td><a href= /uzEr%20Upl0ds/Michael Heintzman.doc > Download</a></td> <td>1001 Laws - Polceing </td> <td><select name="tr2_scatagory"> <option value="1"> Intro To Law </option> <option value="2"> 1001 Laws - Police Foundations </option> </select></td> <td><select name = "tr2_approve"> <option value = "1"> Yes</option> <option value = "2"> no</option> </select></td> </tr> <input type="hidden" name="rowCount" value="2"> <tr> <td><input type="submit" name="sendData" value="send"/></td> </tr> </table> </form> so what I do in my process file is I have a for loop for all of the "TR's" in the table and if it is approved I have an if statment and then I want to add db stuff my problem is my $_POST's are returning blank and I have no idea why. Can someone please assit me with this? (p.s i have debugged and it does get into the if approve == 1 statment. if(isset($_GET['action'])){ if ($_GET['action'] == "approve"){ if(isset($_POST['sendData'])) { $dataArray = array(); $row_count = $_POST['rowCount']; for($i=1;$i<$row_count;$i++) { $approven = "tr".$i."_approve"; $approve = $_POST[$approven]; if($approve == 1) { //Move the info over to "approved files" and delete it out of newnotes $author = "tr".$i."_author"; $location = "tr".$i."_location"; $catagory ="tr".$i."_scatagory"; $filename = "tr".$i."_name"; $submitedby = $_POST['author']; die($submitedby); $dataArray[]=array('author'=>$author,'fileName'=>$fileName,'Catagory'=>$catagory,'location'=>$location); var_dump($dataArray); }else{ //Email user saying they did not recive credits AND delete the entry } } if(!empty($dataArray)) { //now do what you want with the dataArray... var_dumb($dataArray); } } } |