PHP - I Am Lost...i Have Tried Everything I Can Find, But This Form Still Doesn't Work
Ok. I have read everything I could find on how to fix this problem...but nothing seems to work. I have some suspect reasons why I think it doesn't work, but I don't know how to fix it. I read the notice about posting "headers already sent" and nothing in there helped me either. I am at my wits end!
I have a form that is contained in a left navigation file that is an "include" file for other pages of the website. Here is the code for the left navigation file: Code: [Select] <?php //process the email if (array_key_exists('send', $_POST)) { $to = 'jliss32@gmail.com'; $subject = 'Form Submission from JudeLaw LLC for Bankruptcy'; //list expected fields $expected = array('name', 'street','city', 'phone', 'email', 'time', 'hearaboutus', 'otherwho', 'who', 'needs', 'question'); //set required fields $required = array('name', 'street', 'city', 'phone', 'email'); //create empty array for missing fields $missing = array(); // assume that there is nothing suspect $suspect = false; // create a pattern to locate suspect phrases $pattern = '/Content-Type:|Bcc:|Cc:/i'; // function to check for suspect phrases function isSuspect($val, $pattern, &$suspect) { // if the variable is an array, loop through each element // and pass it recursively back to the same function if (is_array($val)) { foreach ($val as $item) { isSuspect($item, $pattern, $suspect); } } else { // if one of the suspect phrases is found, set Boolean to true if (preg_match($pattern, $val)) { $suspect = true; } } } // check the $_POST array and any sub-arrays for suspect content isSuspect($_POST, $pattern, $suspect); if ($suspect) { $mailSent = false; unset($missing); } else { // process the $_POST variables foreach ($_POST as $key => $value) { //assign to temporary variable and strip whitespace if not an array $temp = is_array($value) ? $value : trim($value); //if empty and required, add to $missing array if (empty($temp) && in_array($key, $required)) { array_push($missing, $key); } //otherwise, assign to a variable of the same name as $key elseif (in_array($key, $expected)) { ${$key} = $temp; } } } // validate the email address if (!empty($email)) { // regex to ensure no illegal characters in email address $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/'; // reject the email address if it doesn't match if (!preg_match($checkEmail, $email)) { array_push($missing, 'email'); } } // go ahead only if not suspect and all required fields OK if (!$suspect && empty($missing)) { //set default values for variables that might not exist $hearaboutus = isset($hearaboutus) ? $hearaboutus : 'Nothing selected'; $needs = isset($needs) ? $needs : array('None selected'); //build the message $message = "$name\n\n"; $message .= "$street\n\n"; $message .= "$city\n\n"; $message .= "$phone\n\n"; $message .= "$email\n\n"; $message .= "Best time to reach you? $time\n\n"; $message .= "How did you hear about us? $hearaboutus\n\n"; $message .= "Other: $otherwho\n\n"; $message .= "Referred by: $who\n\n"; $message .= 'What do you need? '.implode(', ', $needs). "\n\n"; $message .= "$question\n\n"; //send it $mailSent = mail($to, $subject, $message); if ($mailSent) { // redirect the page with a fully qualified URL header('Location: http://www.judelawllc.com/contact-thank-you-bk.php'); exit; } } } ?> <div id="sidebarItem1"> <p><a href="http://www.referrallist.com/listing/judelaw-llc.html" target="_blank"><img src="http://www.judelawllc.com/images/martinoLogo.gif" width="216" height="168" alt="Tom Martino Referral List" /></a><br /> <br /> <a href="http://www.bbb.org/denver/business-reviews/60075-112/jude-law-llc-90107441" target="_blank"><img src="http://www.justgoodbusiness.biz/logoonline/getimage.php?bid=90107441&c=blue&h=1" width="187" height="83" border="0" title="Click to verify BBB accreditation and to see a BBB report." alt="Click to verify BBB accreditation and to see a BBB report." /></a></p> <p><img src="http://www.judelawllc.com/images/ColoradoBarAssoc_Logo.jpg" width="180" height="40" alt="Colorado Bar Association" /></p> <p><img src="http://www.judelawllc.com/images/nacba-logo.jpg" width="180" height="35" alt="National Association of Consumer Bankruptcy Attorneys" /></p> <!-- start RatePoint Widget - Please, do not change --> <iframe src="//sitetools.ratepoint.com/widget/36561?style=2&color=3&wide=1&number_of_reviews=1&average_rating=1&rotate_reviews=1&show_links=1" width="200" height="204" scrolling="no" frameborder="0" border="0"> </iframe> <p> <!-- end RatePoint Widget - Please, do not change --> </p> <A class=the_url href="http://ratepoint.com/tellus/36561" target=_blank>Rate us and write a review!</A> </div> <div id="sidebarItem4"> <h1 class="FormFill">Fill out the form below...<br /> Get a Call TODAY!</h1> <div id="sidebarItem4Content"> <?php if ($_POST && isset($missing) && !empty($missing)) { ?> <p class="warning">Please complete the missing item(s) indicated.</p> <?php } elseif ($_POST && !$mailSent) { ?> <p class="warning">Sorry, there was a problem sending your message. Please try again later. If you need immediate assistance, please call(303)757-5833! Thank you.</p> <?php } ?> <form id="contact" method="post" action=""> <p> <label for="name">Name:<?php if (isset($missing) && in_array('name', $missing)) { ?> <span class="warning">Please enter your name</span><?php } ?></label><br /> <input name="name" id="name" type="text" class="formbox" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['name']).'"'; } ?> /> </p> <p> <label for="street">Street Address:<?php if (isset($missing) && in_array('name', $missing)) { ?> <span class="warning">Please enter your street address</span><?php } ?></label><br /> <input name="street" id="street" type="text" class="formbox" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['street']).'"'; } ?> /> </p> <p> <label for="city">City/State/Zip<?php if (isset($missing) && in_array('name', $missing)) { ?> <span class="warning">Please enter your city/state/zip</span><?php } ?></label><br /> <input name="city" id="city" type="text" class="formbox" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['city']).'"'; } ?> /> </p> <p> <label for="phone">Phone:<?php if (isset($missing) && in_array('phone', $missing)) { ?> <span class="warning">Please enter your phone number</span><?php } ?></label><br /> <input name="phone" id="phone" type="text" class="formbox" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['phone']).'"'; } ?>/> </p> <p> <label for="email">E-mail:<?php if (isset($missing) && in_array('email', $missing)) { ?> <span class="warning">Please enter your email</span><?php } ?></label><br /> <input name="email" id="email" type="text" class="formbox" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['email']).'"'; } ?>/> </p> <p> <label for="select">Best Time To Reach You?</label><br /> <select name="time" id="time"> <option value="No reply" <?php if (!$_POST || $_POST['time'] == 'No reply') { ?> selected="selected" <?php } ?> >Select one</option> <option value="Any" <?php if (isset($missing) && $_POST['time'] == 'Any') { ?> selected="selected" <?php } ?> >Any</option> <option value="Morning" <?php if (isset($missing) && $_POST['time'] == 'Morning') { ?> selected="selected" <?php } ?> >Morning</option> <option value="Afternoon" <?php if (isset($missing) && $_POST['time'] == 'Afternoon') { ?> selected="selected" <?php } ?> >Afternoon</option> <option value="Evening" <?php if (isset($missing) && $_POST['time'] == 'Evening') { ?> selected="selected" <?php } ?> >Evening</option> </select> </p> <fieldset id="hearaboutus"> <p><strong class="FormText">How did you hear about us?</strong></p> <p> <input name ="hearaboutus" type="radio" value="Google" id="google" <?php $OK = isset($_POST['hearaboutus']) ? true:false; if($OK && isset($missing) && $_POST['hearaboutus'] == 'Google') { ?> checked="checked" <?php } ?> /> <label for="google">Google</label> <input name ="hearaboutus" type="radio" value="Yahoo" id="yahoo" <?php if ($OK && isset($missing) && $_POST['hearaboutus'] == 'Yahoo') { ?> checked="checked" <?php } ?> /> <label for="yahoo">Yahoo</label> <input name ="hearaboutus" type="radio" value="Bing" id="bing" <?php if ($OK && isset($missing) && $_POST['hearaboutus'] == 'Bing') { ?> checked="checked" <?php } ?> /> <label for="bing">Bing</label> <br /> <input name ="hearaboutus" type="radio" value="Tom Martino" id="tommartino" <?php if ($OK && isset($missing) && $_POST['hearaboutus'] == 'Tom Martino') { ?> checked="checked" <?php } ?> /> <label for="tommartino">Tom Martino</label> <input name ="hearaboutus" type="radio" value="Craigslist" id="craigslist" <?php if ($OK && isset($missing) && $_POST['hearaboutus'] == 'Craigslist') { ?> checked="checked" <?php } ?> /> <label for="craigslist">Craigslist</label> <br /> <input name ="hearaboutus" type="radio" value="Backpage" id="backpage" <?php if($OK && isset($missing) && $_POST['hearaboutus'] == 'Backpage') { ?> checked="checked" <?php } ?> /> <label for="backpage">Backpage</label> <input name ="hearaboutus" type="radio" value="Facebook" id="facebook" <?php if($OK && isset($missing) && $_POST['hearaboutus'] == 'Facebook') { ?> checked="checked" <?php } ?> /> <label for="facebook">Facebook</label> <br /> <input name ="hearaboutus" type="radio" value="AngiesList" id="angieslist" <?php if($OK && isset($missing) && $_POST['hearaboutus'] == 'AngiesList') { ?> checked="checked" <?php } ?> /> <label for="angieslist">Angie's List</label> <br /> <input name ="hearaboutus" type="radio" value="Other" id="othersite" <?php if ($OK && isset($missing) && $_POST['hearaboutus'] == 'Other') { ?> checked="checked" <?php } ?> /> <label for="othersite">Other</label><br /> <label for="otherwho">Please tell us where?</label><br /> <input name="otherwho" type="text" class="formbox" id="otherwho" value="" size="22" <?php if (isset($missing)) { echo 'value="'.htmlentities($_post['otherwho']).'"'; } ?>="<?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['otherwho']).'"'; } ?>" /> <br /> <input name ="hearaboutus" type="radio" value="Referral" id="referral" <?php if ($OK && isset($missing) && $_POST['hearaboutus'] == 'Referral') { ?> checked="checked" <?php } ?> /> <label for="referral">Referral</label><br /> <label for="who">Who referred you?</label><br /> <input name="who" type="text" class="formbox" id="who" value="" size="22" <?php if (isset($missing)) { echo 'value="'.htmlentities($_post['who']).'"'; } ?>="<?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['who']).'"'; } ?>" /> </p> </fieldset> <fieldset id="needs"> <p><strong class="FormText">What do you need?</strong></p> <p> <input type="checkbox" name="needs[]" value="I Want a Free Consultation" id="consult" <?php $OK = isset($_POST['needs']) ? true: false; if ($OK && isset($missing) && in_array('Schedule a showing', $_POST['needs'])) { ?> checked="checked" <?php } ?> /> <label for="consult">I Want a Free Consultation</label> <br /> <input type="checkbox" name="needs[]" value="Have a question" id="havequestion" <?php if ($OK && isset($missing) && in_array('Have a question', $_POST['needs'])) { ?> checked="checked" <?php } ?> /> <label for="haveaquestion">I Have A Question</label> </p> </fieldset> <p> <label for="question">How may we help you?</label><br /> <textarea name="question" cols="22" class="formbox" id="question" <?php if (isset($missing)) { echo 'value="'.htmlentities($_POST['question']).'"'; } ?>"></textarea> </p> <p> <input name="send" id="send" type="submit" value="Send message" /> <input name="reset" id="reset" type="reset" value="Reset Form" /> </p> </form> <br /> </div> </div> Everything worked fine until I wanted to redirect the user to another page for email confirmation. I need to have the user go to a new page so I can use the Google Analytics tracking code for PPC campaigns. So, here is a sample of how this file is included in other pages of the site. I suspect this is the problem, the other pages contain HTML before this file is included. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" /> <title>Thank You! | JudeLaw LLC</title> <meta name="description" content="JudeLaw has a qualified and experienced attorney that practices in all (5) Federal Bankruptcy Courts in Colorado. JudeLaw is the lawyer with the experience that is able to file your case not only in the Denver Bankruptcy Court, but also in Fort Collins, LoveLand, Greeley, Colorado Springs, Grand Junction and Pueblo bankruptcy courts." /> <meta name="keywords" content="about JudeLaw, judelaw, jude law, bankruptcy, personal injury, attorney, lawyer, judelaw employees" /> <!-- STYLES --> <link href="http://www.judelawllc.com/styles/base.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="outerWrapper"> <div id="headerWrapper"><img src="../images/header-logo-01.jpg" width="800" height="137" alt="JudeLaw LLC" /></div> <div id="navWrapper"><?php require ('includes/mainNav.php'); ?></div> <div id="bodyWrapper"> <div id="sidebarWrapper"><?php require ('includes/content-nav-sidebar_thank.php'); ?></div> <div id="contentContainer"> <div id="contentContainerTitle"> <h1>Thank You for contacting us!</h1> </div> <div id="contentContainerBody"> <h5>Your message has been sent.</h5> <p>We will review your inquiry and will be able to help you with your situation very shortly. Thank you for considering Jude Law for your legal needs. <br /><br />If you need immediate assistance, please call 303-757-5833 and someone will be able to assist you. Thank you!</p> <!-- Google Code for contact form thank you Conversion Page --> <script type="text/javascript"> <!-- var google_conversion_id = 1035626379; var google_conversion_language = "en"; var google_conversion_format = "2"; var google_conversion_color = "ffffff"; var google_conversion_label = "9RXqCPXzgwEQi8_p7QM"; var google_conversion_value = 0; if (800.00) { google_conversion_value = 800.00; } //--> </script> <script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js"> </script> <noscript> <div style="display:inline;"> <img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1035626379/?value=800.00&label=9RXqCPXzgwEQi8_p7QM&guid=ON&script=0"/> </div> </noscript> <SCRIPT> microsoft_adcenterconversion_domainid = 799687; microsoft_adcenterconversion_cp = 5050; microsoft_adcenterconversionparams = new Array(); microsoft_adcenterconversionparams[0] = "dedup=1"; </SCRIPT> <SCRIPT SRC="https://0.r.msn.com/scripts/microsoft_adcenterconversion.js"></SCRIPT> <NOSCRIPT><IMG width=1 height=1 SRC="https://799687.r.msn.com/?type=1&cp=1&dedup=1"/></NOSCRIPT><a href="http://advertising.microsoft.com/MSNadCenter/LearningCenter/adtracker.asp" target="_blank">::adCenter::</a> <SCRIPT language="JavaScript" type="text/javascript"> <!-- Yahoo! Inc. window.ysm_customData = new Object(); window.ysm_customData.conversion = "transId=,currency=,amount="; var ysm_accountid = "1TKLPE8MB57H8SOJHVOE3OU6KOO"; document.write("<SCR" + "IPT language='JavaScript' type='text/javascript' " + "SRC=//" + "srv3.wa.marketingsolutions.yahoo.com" + "/script/ScriptServlet" + "?aid=" + ysm_accountid + "></SCR" + "IPT>"); // --> </SCRIPT> </div> </div> <div class="clear"></div> <div id="footerWrapper"><?php require ('includes/footer.php'); ?></div> </body> </html> Please give me some new ideas on what to try in order to make this work. I just need to have the redirect work so I can still use the code for analytics to track conversions. Thank You! Mod edit: [code] . . . [/code] tags added. Similar TutorialsThe file test2.php consists of these simple forms: <?php for($i=0; $i<=5; $i++){ echo "<form action='reset4.php' method='get' name='yourForm'>"; echo "<button type='submit' value='delete' name='remove_" . $i . "' class='deletebtn'>X</button>"; echo "</form>"; } ?> It submits to reset4.php which is this simple code: <?php header("Location: test2.php"); exit; for($i=0; $i<=5; $i++){ if (isset($_REQUEST["remove_$i"])){ echo "Deleted"; }} ?> But it doesn't work. The $_REQUEST doesn't populate the address field and it apparently never gets submitted to reset4.php like it should. This is such a simple program, I can't imagine why it doesn't work. if ($count==1){ header("Location:store.php"); }very simple I have issolated it and it doesn't redirect maybe u can see where my mistake is Ultimate goal is for the query to find the row in the database to avoid the validation and carry on with the rest of the script. What actually happens is the script runs without any parse errors but it doesn't find the row within mysql. $query = sprintf('SELECT name_id, title, description, price, width, height, depth, quantity FROM art WHERE product_code = "$u"', mysql_real_escape_string($product_code, $db)); $result = mysql_query($query, $db)or die(mysql_error($db)); if (mysql_num_rows($result) != 1) { header('Location: home.php'); mysql_free_result($result); mysql_close($db); exit(); } I've echoed the where variable and the mysql_num_rows($result). the where variable is as expected but the result variable comes out as 0. I've checked my phpadmin and there is a entry in there. This worked fine before I sprinted the table. Any help appreciated. Hi, I have a feeling that this is going to be an easy miss but I've been over is a good few times and cannot see what it could be. Essentially, when I post the form in the first set of code (I've got rid of a load of unecessary html) the SESSION variables are not loaded into the second piece of code. Any ideas? Code: [Select] <?php session_start(); require ("connect.php"); $timeout = 1800; $logout_redirect_url = "login.php"; if (isset($_SESSION['start_time'])) { $elapsed_time = time() - $_SESSION['start_time']; if ($elapsed_time >= $timeout) { session_destroy(); header("Location: $logout_redirect_url"); } } $_SESSION['start_time'] = time(); ?> <div id="leftlink"> <a href="logout.php">Logout</a> </div> <table align="center" width="600px" cellpadding="0" cellspacing="0"> <tr> <td> <h2 align="center"><a href="index.php"><img src="images/logo.jpg" border="0" /></a> <br /> Emergency</h2> <hr /> </td> </tr> </table> </head> <body> <form action="post_reset.php" method="post" name"passre"> <table width="500" border="0" align="center" cellpadding="2" cellspacing="1"> <tr> <td width="230"><div align="right">E-mail Address : </div></td> <td width="40"> </td> <td width="230"><div align="left"> <input name="email" readonly="readonly" value="<?php echo ($_SESSION['email']) ; ?>" /></div></td> </tr> <tr> <td colspan="3"><div align="center"><input type="submit" name="submit" value="Submit" /></div></td> </tr> </table> </form> </body> </html> Code: [Select] <?php session_start; echo ($_SESSION['start_time']); require ("connect.php"); if (isset($_POST['submit'])){ $email = $_POST['email']; $getde = "SELECT * FROM users WHERE email = '$email'"; $getder = mysql_query($getde, $conn); $getdere = mysql_fetch_array($getder) Thanks Gareth I've joined querys because I'm making my own forums. However, when it gets to the echoin out part, it shows the category and only ONE of the sub categorys. Code: [Select] <div id="forumContainer"> <?php $lastboard = ''; $forumQ = mysql_query("SELECT f1.cat_name as catName, f1.cat_id as catID, f2.cat_id as subCatID, f2.sub_id as subID, f2.sub_name as subName, f2.sub_desc as subDesc FROM `forum_cats` as f1 LEFT JOIN `forum_sub` as f2 ON f1.cat_id = f2.cat_id GROUP BY f2.cat_id "); while($forumF = mysql_fetch_assoc($forumQ)) { if($forumF['catName'] != $lastboard) { echo '<div class="forumCat">'.$forumF['catName'].'</div>'; $lastboard = $forumF['catName']; } echo '<div class="forumSub">'.$forumF['subName'].'</div>'; } ?> </div> $Row[2] doesn't work but if I use $Row["linkcat"] than it works fine. Is there somewhere to activate in the php.ini file ? Code: [Select] // I got 9 fields to in the table tbl_link ! $Row[2] should give me a number. $Verbinding = mysql_connect($db_host, $db_user, $db_passw); mysql_select_db($db_name); $sql = "Select * from tbl_link where userid=1"; $ResultShow = mysql_query($sql); while ($Row = mysql_fetch_assoc($ResultShow)){ echo $Row[2]; } Hi everybody! I'm creating a site and none of my php-code works. I tried to do a simple php-code to test it but it doesn't work either. The simple php-code: <?php echo "hello"; ?> Hi, I am trying to get the previous id for the table xdocument, but browser outputs this warning: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given for this code: Code: [Select] <?php //HELPER FCN used by FCN: writeXMLtoDBviaDOM function mysql_next_id($table) { $result = mysql_query('SHOW TABLE STATUS LIKE "'.$table.'"'); $rows = mysql_fetch_assoc($result); return $rows['Auto_increment']; } //TEST RUN: $_filePath="C:\dir\email.xml"; $node=basename($_filePath); $dom=new DOMDocument(); $dom->load($node); $labelPath=array(); mysql_connect("localhost","root"); mysql_select_db("dummydpev"); $isXdocExist=mysql_query("SELECT (file_Path,file_Name) FROM xdocument WHERE file_Path='$_filePath' AND file_Name='$node'"); $docId=0; if(mysql_num_rows($isXdocExist)==0) { mysql_query("INSERT INTO xdocument (file_Path,file_Name) VALUES ('$_filePath','$node')"); $docId=mysql_next_id("xdocument")-1; } else $docId=mysql_next_id("xdocument")-1; writeXMLtoDBViaDOM($dom->documentElement,$labelPath,$docId,$_filePath); ?> So I think my problem is with the multiple WHERE clause conditions, can I do it like what I have above? Any help much appreciated! Hey, $todo_upgrades_sql = "SELECT * FROM todo_upgrades WHERE time_completion >= $time"; $todo_upgrades_res = mysql_query($todo_upgrades_sql) or die (mysql_error()); results: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 I've written a script where it counts the page impressions on my website. When a visitor lands on the page, it counts their impression and then sets a $_SESSION so that if they reload or return to the page it doesn't count it again. But the problem is it sometimes does. Does this mean that the $_SESSION isn't being set probably? That's what it seems to be. And if so, what would be the reason for that? Here's my basic code: Code: [Select] if(isset($_SESSION['userid'])){ $userid = $_SESSION['userid']; } else{ $userid = rand(1000, 10000000); $_SESSION['userid'] = $userid; } $date = date('Y-m-d'); $counters = mysql_query("SELECT * FROM counters WHERE userid='$userid' AND impressions='1' AND date='$date'") or die(mysql_error()); if(!mysql_num_rows($counters)){ mysql_query("INSERT INTO counters (userid, impressions, date) VALUES('$userid', '1', current_date)") or die(mysql_error()); } Hello all, I'm trying to clean up some user input for my database but the mysql_real_escape_string function doesn't seem to work, and neither does addslashes(). I've browsed the net and made sure I'm connected to the database before the function is called. I can't figure out what I'm doing wrong. Here's the relevant part of the code: Code: [Select] <?php mysql_connect("localhost","adminname","adminpassword") or die (mysql_error()); mysql_select_db("databasename") or die (mysql_error()); $comment=mysql_real_escape_string($_POST['commentbox']); ?> ...and then the result is put into the database along with some other data. The database entry is correct, except, when I check the database or echo the result I get the same thing that was entered into 'commentbox'. For instance, if I enter "I am very 'confused' by this" into the box, the same string will be found in the database table. No slashes, just quotes. Anyone have an idea what's wrong with this? Because it all seems simple and correct but doesn't work. Another issue with trying to work on somebody else's script (and on no sleep!) I've got this mess of a page I'm trying to manipulate to add a feature to. When somebody goes to this page, it pulls all records. At the top, I added a way to refine the results by dates. That query works fine, I tested it in mysql. To avoid fighting with the original code, I created an if statement to create $query_selectAll. But when I put it in the page, it would just refresh with the same data. I echoed the query to make sure it is correct. Then I realized that there was another query, $query_selectAllItems, further down the page that was generating the results, and none of what I was doing made a difference. But I'm not sure why it's ignoring my query or how to work around this. I tried deleting the query $query_selectAllItems, thinking it would take mine, because it ends with the same: $result_all $result_all = mysql_query($query_selectall); or $result_all = mysql_query($query_selectAllItems); Code: [Select] <?php require_once('calendar/classes/tc_calendar.php'); include("include/auth.php"); include("include/conn.php"); @$a_row = mysql_fetch_array($result); // I added this if statement in to get my POST results, without having to make changes to the GET results he made. if (isset($_POST['view'])){ $view=$_POST['view']; } else { $view=$_GET['view']; } if ($view=="All") { $query_selectall = 'select * from tbl_registration'; echo $query_selectall; } elseif ($view=="dated") { $mydate = isset($_REQUEST["date5"]) ? $_REQUEST["date5"] : ""; $end_date = isset($_REQUEST["date6"]) ? $_REQUEST["date6"] : ""; $query_selectall = "SELECT * FROM tbl_registration WHERE reg_timestamped BETWEEN STR_TO_DATE('$mydate', '%Y-%m-%d') AND STR_TO_DATE('$end_date' , '%Y-%m-%d')"; echo $query_selectall; } else { $query_selectall = "select * from tbl_registration where category='$view'"; echo $query_selectall; } $result_all = mysql_query($query_selectall); @$numRows_all = mysql_num_rows($result_all); ?> <title>WYF Admin</title> <html> <head> <script language="javascript" src="calendar/calendar.js"></script> <link href="include/styles.css" rel="stylesheet" type="text/css"> <SCRIPT language="JavaScript"> <!-- function confirm_delete(idval) { var verify= confirm("Do you really want to delete this Registration?"); if (verify== true) { window.location="delete_registrations.php?action=delete&did=" + idval; } } //--> </SCRIPT> <script type="text/javascript" src="js/jquery-latest.js"></script> <script type="text/javascript" src="js/jquery.tablesorter.js"></script> <script type="text/javascript"> $(function() { $("table").tablesorter({debug: true}); }); </script> </head> <body leftmargin="0" rightmargin="0" bottommargin="0" topmargin="0" cellspacing="0" cellpadding="0" bgcolor="ffffff"> <table width="100%"><tr><td align="left"><img src="images/logo.jpg"></td></tr> <tr><td><hr></td></tr> </table> <table><tr><td valign="top"> <table cellspacing="1" cellpadding="0" bgcolor="#cccccc" border="0" width="300"> <tr><td> <table cellspacing="0" cellpadding="0" width="300" height="400" bgcolor="#ffffff" border="0"> <tr><td align="left" valign="top"> <table width="250"><tr><td valign="top"> <b>Welcome </b><br><br> <?php //$query_selectAllItems = "SELECT *, DATE_FORMAT(workshop_date, '%e-%m-%Y') as 'my_date' FROM tbl_workshops"; $query_selectAllItems = "SELECT * FROM tbl_registration"; $result_all = mysql_query($query_selectAllItems); $numRows_all = mysql_num_rows($result_all); ?> <? include "include/nav.php"; ?> </td></tr></table></center> </td></tr> <tr><td></td></tr></table></tr></td></table> </td><td valign="top"> <div style="float:left;padding-right:40px;"><a href="getcsv.php">export to csv</a></div><div> <div style="float:right;margin-right:100px;"><form name="form1" method="post" action="viewregistrations2.php"><div style="float:left;overflow:visible;padding-right:10px;">View between</div> <div style="float:left;overflow:visible;padding-right:10px;"> <?php $myCalendar = new tc_calendar("date5", true, false); $myCalendar->setIcon("calendar/images/iconCalendar.gif"); $myCalendar->setDate(date('d'), date('m'), date('Y')); $myCalendar->setPath("calendar/"); $myCalendar->setYearInterval(2000, 2015); $myCalendar->dateAllow('2008-05-13', '2015-03-01'); $myCalendar->setDateFormat('j F Y'); $myCalendar->setAlignment('left', 'bottom'); $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year'); $myCalendar->setSpecificDate(array("2011-04-10", "2011-04-14"), 0, 'month'); $myCalendar->setSpecificDate(array("2011-06-01"), 0, ''); $myCalendar->writeScript(); ?> </div> <div style="float:left;overflow:visible;padding-right:10px;"> and </div> <div style="float:left;overflow:visible;padding-right:10px;"> <?php $myCalendar = new tc_calendar("date6", true, false); $myCalendar->setIcon("calendar/images/iconCalendar.gif"); $myCalendar->setDate(date('d'), date('m'), date('Y')); $myCalendar->setPath("calendar/"); $myCalendar->setYearInterval(2000, 2015); $myCalendar->dateAllow('2008-05-13', '2015-03-01'); $myCalendar->setDateFormat('j F Y'); $myCalendar->setAlignment('left', 'bottom'); $myCalendar->setSpecificDate(array("2011-04-01", "2011-04-04", "2011-12-25"), 0, 'year'); $myCalendar->setSpecificDate(array("2011-04-10", "2011-04-14"), 0, 'month'); $myCalendar->setSpecificDate(array("2011-06-01"), 0, ''); $myCalendar->writeScript(); ?> </div> <div style="float:left;overflow:visible;padding-right:10px;"><input type="hidden" name="view" id="view" value="dated"><input type="submit" value="go!"> </div></form> </div><br><br><br><br> <table width="95%" border="1" cellpadding="3" cellspacing="1" bordercolor="#999999" id="rowspan" class="tablesorter" name="table"><thead> <tr bgcolor="#ffffff"> <th width="125">Name</th> <th width="125">Address</th> <th width="125">Phone</th> <th width="125">Email</th> <th width="125">Workshop</th> <td width="50"> </td> <td width="50"> </td><td> </td> </tr></thead> <tbody> <? //output each row while ($c_row = mysql_fetch_array($result_all)){ ?> <tr> <td><?= $c_row['reg_fname'] ?> <?= $c_row['reg_lname'] ?></td> <td><?= $c_row['reg_address'] ?></td> <td><?= $c_row['reg_phone'] ?></td> <td><?= $c_row['reg_email'] ?></td> <td> <?php $catid = $c_row['reg_workshopid']; $query="SELECT * FROM tbl_workshops where workshop_id = '$catid'"; //Run query; $result=@mysql_query($query); $row=mysql_fetch_array($result); ?> <?php echo($row['workshop_title']); ?> </td> <td width="50" bgcolor="#DEE1EB"><div align="center"><a href="edit_registration.php?id=<? print $c_row['reg_id'] ?>">edit</a></div></td> <td width="50" bgcolor="#DEE1EB"><div align="center"><a href="javascript://" onClick="confirm_delete(<? print $c_row['reg_id'] ?>); return false">delete</a></div></td> <td width="50" bgcolor="#DEE1EB"><div align="center"><a href="printregistration.php?regid=<? print $c_row['reg_id'] ?>">view all / print</a></div></td> </tr> <? } //end while ?> </tbody> </table><br><br> </td></tr></table> Hi guys, me again. I have been using mail to send emails ( With your great help ) successfully in about three websites. For some reason, my email doesn't want to work with the site I am busy with now. This is my code : Code: [Select] <html> <head> <title>Practice</title> </head> <body> <table border="1"> <tr> <td> <?php $emailto="hannes@ncc-cla.com"; $emailsubject="confirmation"; $emailfrom="footloose.sa@gmail.com; if(!empty($_POST['uname'])){ $yourname=$_POST['uname']; $yoursurname=$_POST['usurname']; echo "hello </td> <td>" ." " . "$yourname" . " " . "$yoursurname </td> </tr>"; $emailbody="hello </td> <td>" ." " . "$yourname" . " " . "$yoursurname </td> </tr>"; } else{ echo"<tr> <td> enter your name </td> </tr>"; $emailbody .="<tr> <td> enter your name </td> </tr>"; } if(isset($_POST['gender'])){ /*isset is what it is set to can be used */ $gender=$_POST['gender']; echo "<tr> <td> You are a </td> <td> " . " " . "$gender </td> </tr>"; $emailbody .="<tr> <td> You are a </td> <td> " . " " . "$gender </td> </tr>"; } else{ echo "<tr> <td> Select Gender </td> </tr>"; $emailbody .="<tr> <td> Select Gender </td> </tr>"; } if(isset($_POST['plang'])){ $plang=$_POST['plang']; echo "<tr> <td> You are interested in </td> <td> " . " " . "$plang </td> </tr>"; $emailbody .="<tr> <td> You are interested in </td> <td> " . " " . "$plang </td> </tr>"; } else{ echo "<tr> <td> Select Programming language </td> </tr>"; $emailbody .="<tr> <td> Select Programming language </td> </tr>"; } print "<tr> <td> Your qualification is </td> <td>"; $emailbody .= "<tr> <td> Your qualification is </td> <td>"; foreach ($_POST['qlevel'] as $level){ print "$level<BR>"; $emailbody .="$level<BR>"; } $headers='From:'. $emailfrom; mail($emailto,$emailsubject,$emailbody,$headers); ?> </td> </tr> </table> </body> </html> Im using func_get_args, but it gives an error?: Too few arguments?, when its correct (as the number of %s = the number of values within $args) <?php function sprintify() { global $urls; $args = func_get_args(); $input = $args[0]; unset($args[0]); return sprintf($urls[$input], implode(', ', $args)); } echo sprintify('default', 46, 464, 46); /* For your information: $urls['default'] = '%s/%s/%s'; */ ?> I just started with php and made an image. But when I try to open it in my browser, it shows a broken image icon. I have put the font in the same folder as the .php file, but it doesn't work. Can somebody help me solve this problem? Here is the code: Code: [Select] <?php $font_path = "nakedchick.TTF"; $font_size = 30; $img_number = imagecreate(300,50); $backcolor = imagecolorallocate($img_number,0,162,255); $textcolor = imagecolorallocate($img_number,255,255,255); imagefill($img_number,0,0,$backcolor); $number = " So your ip is $_SERVER[REMOTE_ADDR]? "; ImageTTFText($img_number, $font_size,10,5,5,$number,$font_path,$textcolor); header("Content-type: image/png"); imagepng($img_number); ?> And also the files: (.php in attachment) http://falcogerritsjans.nl/u/signature2.php http://falcogerritsjans.nl/u/nakedchick.ttf I've been puzzling over this all morning. No matter what I do i keep getting these errors: Quote
[01-Oct-2019 21:45:32 UTC] PHP Warning: Use of undefined constant PASSWORD_BCRYPT - assumed ' PASSWORD_BCRYPT' (this will throw an Error in a future version of PHP) in /home/ijwe4nfwf9ei/public_html/blog-approval.php on line 7 Here's my code: <?php echo phpinfo(); $pass=password_hash ("password", PASSWORD_BCRYPT); ?> I checked and I'm using php 7, so why do I keep getting this error? I had it print out my php info so I could check.. https://pyro-creations.com/tester.php I even read the manual and tried the examples and I still get those errors. How can I fix this? [please use code tags.] Hello, I've been working on some stuff, and get the information parsed like this: Code: [Select] Value1,Value2,Value3 0.68,4377.54,11069.02So I'm trying to explode it and insert the latest numbers into the database. I'm using: $value = explode(",", $variable); $secondsplit = explode(" ", $value[2]); mysql_query("INSERT INTO table(row) VALUES('".mysql_real_escape_string($secondsplit[1])."')"); The problem is that it has something like an enter in the database, or a space. But I can't figure out how to get rid of that problem. Does anyone know what's wrong? Regards, NLCJ Hey, I have made a audio button in dreamweaver and copied the code into my php panel: <script language="JavaScript" src="http://www.MYWEBSITE.com/myname/audio/audio-player.js"></script> <object type="application/x-shockwave-flash" data="http://www.MYWEBSITE.com/media_folder/audio/player.swf" id="audioplayer1" height="24" width="290"> <param name="movie" value="http://www.MYWEBSITE.com/media_folder/audio/player.swf"> <param name="FlashVars" value="playerID=audioplayer1&soundFile=http://www.MYWEBSITE.com/media_folder/audio/Reconstructed Ancient Egyptian Melody.mp3"> <param name="quality" value="high"> <param name="menu" value="false"> <param name="wmode" value="transparent"> </object> However once I press save, all that is saved is: <script language="JavaScript" src="http://www.MYWEBSITE.com/myname/audio/audio-player.js"></script> <object type="application/x-shockwave-flash" data="http://www.MYWEBSITE.com/media_folder/audio/player.swf" id="audioplayer1" height="24" width="290"> <param name="movie" value="http://www.MYWEBSITE.com/media_folder/audio/player.swf"> The audio button works however because the code which includes the mp3 file never saves, it can never find the audio file. Can anyone tell me why the audio file part of the code doesn't save? Thanks. Hi, when I output this, it's same order, I want it to be: email/message/to/toLastName please see code: $testArray=array("toLastName","to","message","email"); $reversedTestArray=rsort($testArray);//rsort returns TRUE on success //$strTestArrayReversed=implode(",",$testArray); print_r($testArray); Any idea what I am doingwrong, it looks fairly straightforward. Any help much appreciated! |