PHP - Php Function Not Working Properly??
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.. Similar TutorialsOkay 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 } ?> I have a simple php script that updates my sitemap automatically. However, when you click the link to the sitemap at www.bomstudies.com/sitemap-xml.php - the last mod date is showing 1969. The php script works for files that are not in sub folders. such as /talks or /commentary. I just need to know what snippet of code i should add, change, or delete to the sitemap php side of it to show the correct last mod date for my xml sitemap. I greatly appreciate your help.
Thanks -
Here is some of my code:
The Config Code: posted as config.php
<?php 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, 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> 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"; } ?> 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 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!"; } 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! 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"; ?> 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! I have this function which is javascript and I need to convert it to php.. Code: [Select] function US2dec(myUS) { if (myUS.toLowerCase() == 'even') { myUS = '100'; } var myDec; myUS = parseFloat(myUS); if (Math.abs(myUS) < 100 || isNaN(myUS)) { myDec = NaN; } else if (myUS > 0) { myDec = 1 + myUS / 100; } else { myDec = 1 - 100 / myUS; } return myDec.toFixed(8); } I came up with this php version and it seems to work but I'm no expert with math functions.. I was hoping somebody who's a bit more familiar with these functions could check it over quick.. Code: [Select] function US2dec($myUS) { if (strtolower($myUS) == 'even') { $myUS = 100; } $myDec = 0; $myUS = floatval($myUS); if (abs($myUS) < 100 || !is_numeric($myUS)) { $myDec = 0; } else if ($myUS > 0) { $myDec = 1 + $myUS / 100; } else { $myDec = 1 - 100 / $myUS; } return number_format($myDec,8); } Thanks!! I have been searching for an answer for several days but have not yet resolved my problem. Essentiallty I started out looking for an image upload script then slowly went towards just a basic upload script. Each time I try a new script I am getting the same error. My folder permissions are set, file uploads is enabled, safe mode is disabled. As of right now my page is giving me an error that says 'Failed to open stream' My existing code: Code: [Select] <?php $target = "images/"; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; //This is our size condition if ($uploaded_size > 350000) { echo "Your file is too large.<br>"; $ok=0; } //This is our limit file type condition if ($uploaded_type =="text/php") { echo "No PHP files<br>"; $ok=0; } //Here we check that $ok was not set to 0 by an error if ($ok==0) { Echo "Sorry your file was not uploaded"; } //If everything is ok we try to upload it else { if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "Sorry, there was a problem uploading your file."; } } ?> <form enctype="multipart/form-data" action="uploader.php" method="POST"> Please choose a file: <input name="uploaded" type="file" /><br /> <input type="submit" value="Upload" /> </form> You for testing purposes I have made my temporary upload page available for you to view and help disgnose the issue: http://www.sophienoelle.me/uploader.php also you can find the phpinfo at http://www.sophienoelle.me/phpinfo.php If you need further information than what I have supplied please let me know and I will be available to provide what you are requesting. If you have a suggestion I will gladly take it. Any steps I can get to uploading images the better. 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); } } } 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> Unable to submit choosing a file. This feature should be optional, Please assist. Thank you. php code ========= <?php $page = 'contact'; require "header.php"; ?> <?php $statusMsg=''; if(isset($_FILES["file"]["name"])){ $email = $_POST['email']; $fname = $_POST['fname']; $lname = $_POST['lname']; $phone = $_POST['phone']; $company = $_POST['company']; $option = $_POST['option']; $message = $_POST['message']; if(!empty($_POST['check_list'])) { $checks = array(); foreach($_POST['check_list'] as $check) { $checks[] = $check; } $check = implode('</br>•', $checks); } $fromemail = $email; $subject="MyGeo - Contact Us"; $email_message = '<h2>User Information</h2> <p><b>First Name:</b> '.$fname.'</p> <p><b>Last Name:</b> '.$lname.'</p> <p><b>Email:</b> '.$email.'</p> <p><b>Phone:</b> '.$phone.'</p> <p><b>Company:</b> '.$company.'</p> <p><b>Please choose a category :</b> '.$option.'</p> <p><b>Your message to MyGeo :</b> '.$message.'</p>'; $email_message.="Please find the attachment"; $semi_rand = md5(uniqid(time())); $headers = "From: ".$fromemail; $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; if($_FILES["file"]["name"]!= ""){ $strFilesName = $_FILES["file"]["name"]; $strContent = chunk_split(base64_encode(file_get_contents($_FILES["file"]["tmp_name"]))); $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message .= "\n\n"; $email_message .= "--{$mime_boundary}\n" . "Content-Type: application/octet-stream;\n" . " name=\"{$strFilesName}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $strContent .= "\n\n" . "--{$mime_boundary}--\n"; } $toemail="jasmin.ambrose@mygeo.my"; if(mail($toemail, $subject, $email_message, $headers)){ $statusMsg= "Submission succesful, thank you for contacting MyGeo"; }else{ $statusMsg= "SUBMISSION FAILED, please submit again later, thank you"; } } ?> <!-- Display submission status --> <?php if(!empty($statusMsg)){ ?> <h1 class="container jumbotron text-uppercase text-center mx-auto" style=" font-size: 25px; color: green;"><?php echo $statusMsg; ?></h1> <?php } ?> <!-- Sectio-one --> <div class="col-md-12 square"> <h3 class="font-weight-bold"></h3> <h4 class="font-weight-bold">MyGeo Sdn. Bhd. (1367062-K)</h4> <h5>Level 2, Suite IIC Resource Centre, Technology Park Malaysia, Bukit Jalil, 57000 Kuala Lumpur, MALAYSIA</h5> <i class="fa fa-envelope-o" aria-hidden="true"></i> contactus@mygeo.my <i class="fa fa-phone" aria-hidden="true"></i> +6012 345 3263 </div> <div class="section-service py-5 my-1"> <div class="container"> <div class="row p-1"> <div class="col-xs-6"> <h1>HOW CAN WE HELP YOU</h1> </div> </div> <div class="row p-1"> <div class="col-md-12"> <p id="sep">Contact us below with new project requests, feedback and general questions</p> <form method="post" action="" enctype="multipart/form-data"> <div class="form-row"> <div class="form-group col-md-6"> <label class="font-weight-bold" for="fname">First Name</label> <input name="fname" type="text" class="form-control" placeholder="First name" required> </div> <div class="form-group col-md-6"> <label class="font-weight-bold" for="lname">Last Name</label> <input name="lname" type="text" class="form-control" placeholder="Last name" > </div> </div> <div class="form-row"> <div class="form-group col-md-6"> <label class="font-weight-bold" for="inputEmail4">Email</label> <input name="email" type="email" class="form-control" id="inputEmail4" placeholder="Email" required> </div> <div class="form-group col-md-6"> <label class="font-weight-bold" for="Phone">Phone</label> <input name="phone" type="tel" class="form-control" id="phone" placeholder="Enter phone number" required> </div> </div> <div class="form-row"> <div class="form-group col-md-6"> <label class="font-weight-bold" for="company">Company</label> <input name="company" type="text" class="form-control" placeholder="Company" > </div> </div> <div class="form-row"> <div class="form-group"> <label class="font-weight-bold" for="input" required>Please choose a category :</label> <div class="form-check"> <input class="form-check-input" <?php if (isset($option) && $option=="General Questions") echo "checked";?> value="General Questions" type="radio" name="option" id="exampleRadios1" checked> <label class="form-check-label" for="exampleRadios1"> General Questions </label> </div> <div class="form-check"> <input class="form-check-input" <?php if (isset($option) && $option=="New Project Request") echo "checked";?> value="New Project Request" type="radio" name="option" id="exampleRadios1" checked> <label class="form-check-label" for="exampleRadios1"> New Project Request </label> </div> <div class="form-check"> <input class="form-check-input" <?php if (isset($option) && $option=="Feedback") echo "checked";?> value="Feedback" type="radio" name="option" id="exampleRadios1" checked> <label class="form-check-label" for="exampleRadios1"> Feedback </label> </div> </div> </div> <div class="form-group"> <label class="font-weight-bold" for="Textarea1">Your message to MyGeo</label> <textarea class="form-control" id="FormTextarea1" rows="3" name="message" required></textarea> <small id="emailHelp" class="form-text text-muted">0 of 4000 max charaacters</small> </div> <p></p> <p></p> <div class="form-group"> <label class="font-weight-bold" for="File1"></label> <input type="file" name="file" class="form-control-file" id="exampleFormControlFile1" required =""> </div> <button type="submit" class="btn btn-success" name="submit">Submit</button> </form> </div> </div> </div> </div> <?php require "footer.php"; ?>
footer.php ======= <!-- Footer --> <section id="footer"> <div class="container text-center"> <div class="row social"> <div class="col-xs-12 col-sm-12 col-md-12 mt-2 mt-sm-2"> <ul> <li class="list-inline-item"> <a href="#"><i class="fa fa-linkedin"></i></a></li> <li class="list-inline-item"> <a href="#"><i class="fa fa-twitter"></i></a></li> <li class="list-inline-item"> <a href="https://www.facebook.com/MyGeo-100967235334783"><i class="fa fa-facebook"></i></a></li> </ul> </div> </div> <div class="row"> <div class="col-xs-12 col-md-12 mt-2 mt-sm-2 text center text-white"> <p>© All Rights Reserved (2020)<a href="#"> MyGeo</a> Sdn. Bhd. (1367062-K)</p> <p>Level 2 Suite IIC Resource Centre Technology Park Malaysia, Bukit Jalil, 57000 Kuala Lumpur, MALAYSIA.</p> </div> </div> </div> </section> <script> function myFunction() { var input, filter, ul, li, a, i; input = document.getElementById("mySearch"); filter = input.value.toUpperCase(); ul = document.getElementById("myMenu"); li = ul.getElementsByTagName("li"); for (i = 0; i < li.length; i++) { a = li.getElementsByTagName("a")[0]; if (a.innerHTML.toUpperCase().indexOf(filter) > -1) { li.style.display = ""; } else { li.style.display = "none"; } } } </script> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script> </body> </html>
header.php ======== <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>My GEO</title> <link rel="shortcut icon" type="image/png" href="images/mygeo logo2.png"> <link rel="stylesheet" href="./css/style.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous"> </head> <body> <!-- Simple Responsive Navbar --> <nav class="navbar navbar-expand-xl text-success font-weight-600 pt-2"> <div class="container"> <a class="navbar-brand" href="index.php"><img style="width: 15vh;" src="images/mygeo logo2.png"></a> <button class="navbar-toggler navbar-light" data-toggle="collapse" data-target="#Nav"> <span class="navbar-toggler-icon"></span> </button> <div class="collapse navbar-collapse" id="Nav"> <ul class="navbar-nav" id="myMenu"> <li class="nav-item <?php if($page=='about'){echo 'active';}?>"> <a class="nav-link" href="about.php">ABOUT US</a> </li> <li class="nav-item <?php if($page=='services'){echo 'active';}?>"> <a class="nav-link" href="services.php">SERVICES</a> </li> <li class="nav-item <?php if($page=='projects'){echo 'active';}?>"> <a class="nav-link" href="projects.php">PROJECTS</a> </li> <li class="nav-item <?php if($page=='people'){echo 'active';}?>"> <a class="nav-link" href="people.php">MYGEO PEOPLE</a> </li> <li class="nav-item dropdown <?php if($page=='careers'){echo 'active';}?>"> <a class="nav-link dropdown-toggle " data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">CAREERS</a> <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <a class="dropdown-item" href="career-a.php">TELL US ABOUT YOURSELF</a> <a class="dropdown-item" href="career-b.php">JOB OPENINGS</a> </div> </li> <li class="nav-item <?php if($page=='blog'){echo 'active';}?>"> <a class="nav-link" href="https://mygeomalaysia.wordpress.com/">BLOG</a> </li> <li class="nav-item <?php if($page=='webmail'){echo 'active';}?>"> <a class="nav-link" target="_blank" href="https://mygeo.my/webmail">WEBMAIL</a> </li> <li class="nav-item <?php if($page=='contact'){echo 'active';}?>"> <a class="nav-link" href="contact-a.php">CONTACT US</a> </li> </ul> </div> </div> </nav>
Edited April 19 by requinix please use the Code <> button when posting code $db->query( "UPDATE user_resources, user_buildings, user_units_nonbattle SET user_resources.uGold=user_resources.uGold+(user_buildings.uTownCenterLevel*(user_units_nonbattle.uMiner*10))" ); When the cron runs, it updates everyone the same regardless. Any idea what i'm doing wrong? Hi everyone, I am trying to implement an OAuth system in PHP. I've got the code working but the very first time a fresh, new browser window is opened, the code doesn't work. If I refresh the page and try again, then it works. I have a few suspicions as to where the problem might be but other than that I am stumped. I have two classes: OAuthServer and OAuthClient. I create and store an object of the appropriate class in session variables. I know this is tricky but I am serializing and unserializing properly. To fetch responses from the Server, I am using curl. As curl uses a different session from the browser, I am doing a session_write_close before initializing curl and passing the appropriate parameters to curl. But my code needed to further write session variables even after session_write_close was called and to achieve this, I am calling session_start(), once again, after the curl code is finished. I found that this works but PHP was throwing warnings saying that the header info had already been sent or something like that, but I have suppressed such warnings. I suspect the error has something to do with this but I'm not sure. The part that doesn't work the very first time is that on the server-side, the session variable that is supposed to contain the OAuthServer object is NULL. But if I do a refresh of the page(flow: login_page->error_page), it works. Can anyone tell me why I am encountering the above error and if I am doing things correctly or not. Any help would be greatly appreciated. Thanks & Regards, GarbageGigo 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 Hello Everyone So i have this script that pulls some stuff out of a db and displays it. Pretty basic. It used to work fine but now it omits one entry from the table. It always shows one less than its supposed to. I.E. if there are 4 table entries, it only shows 3. It didnt do this before and I'm not sure why it changed. I didnt edit the code at all. Here it is: Code: [Select] else{ $sql = "SELECT * FROM article WHERE lang='" . $validlang ."' AND cat_id=" . $validentry . " ORDER BY id DESC LIMIT 5"; $result = mysql_query($sql); if(!$result){ echo "Error querying the database." . mysql_error(); exit; } else{ $row = mysql_fetch_assoc($result); } if(!$row){ echo "Error: No articles found." . mysql_error(); exit; } else{ echo "<div id='section'>Organization News</div>"; while($row = mysql_fetch_assoc($result)){ echo "<h3><a href='" . $validlang . "/" . $row['location'] . "'>" . $row['title'] . "</a></h3>"; echo "<div id='subtitle'>" . $row['summary'] . "</div>"; } } } Any help would be appreciated. Thanks |