Jump to content

Search the Community

Showing results for tags 'php'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

Found 928 results

  1. westman

    cookie coding

    Hi all, I am coding cookies for the first time and here is what I have. setcookie("username", $old_cookie, "1", "/", "", "", TRUE); setcookie("username", $new_cookie, strtotime( '+30 days' ), "/", "", "", TRUE); Is this the right way of resetting the value of one cookie? ps. I did read a lot on http://php.net/manual/en/function.setcookie.php but it is not clear.
  2. Sigmahokies

    Validation form

    Hi everyone, I am trying to have validation form, seem it doesn't work. what did I do wrong? If anyone can help, Thank you so much... Gary Taylor <?php $buzz = $buzz2 = ""; if ($_SERVER['REQUEST_METHOD'] == "POST") { if (empty($_POST['select'])) { $buzz = "<h2><color ='red'> >- </color></h2>"; $buzz2 = "<h2><color ='red'> -< </color></h2>"; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Welcome to ASL-PT Scoring</title> <link href="default.css" rel="stylesheet" type="text/css"> </head> <body> <fieldset> <h1>Welcome to ASL-PT Scoring website</h1> <table> <form action="login.php" method="post"> <select name="select"> <?php echo $buzz ?><option value="" >Please select the level</option><?php echo $buzz2 ?> <option value="Administrator">Administrator</option> <option value="License">License</option> <option value="Scorer">Scorer</option> </select> <caption>Please login to enter the site below:</caption> <tr><td>Username:</td><td class="td"><input type="text" name="user"></td></tr> <tr><td>Password:</td><td class="td"><input type="password" name="password"></td></tr> <tr><td colspan="2"><input type="submit" name="submitted" value="Login"></td></tr> </form> </table> </fieldset> </body> </html>
  3. BACKGROUND: My jubilation was short-lived. For the internal server error that was plaguing my site in general is now plaguing a crucial file in particular. Please find below a file that works perfectly well on my local test server, but fails with an internal server error on my host server. Please also note that the file matomo/index.php is located on the same server as that from which the cURL call is made, but under a different domain name. ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log'); ini_set('html_errors', 0); ini_set('display_errors', 0); error_reporting(E_ALL); $url = 'https://.../matomo/index.php?module=API&method=API.getIpFromHeader&format=JSON&token_auth=...'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, false); curl_exec($curl_request); curl_close($curl_request); QUESTION: Does cURL not work in such an environment? If it does, then what must I do to make it work? The error.log file contains nothing and the AJAX that made the call does not complain of not being able to access the file. Roddy
  4. BACKGROUND: A visitor arrives on a website. While still on the site he triggers an AJAX call that fills a <div> element with new HTML. Once the page is filled another AJAX call is made that seeks to read the following value as encoded JSON: $_SERVER['REMOTE_REFERER']. Instead I receive a 500 internal server error. The AJAX (function() { $("#main").html(''); $("<link/>", { rel: "stylesheet", type: "text/css", href: "./_utilities/css/yourprofile_filler.css" }).appendTo("head"); $.get('./yourprofile_filler.html', function(data) { $('#main').html(data); }).done(function(){ $.ajax({ url: './_utilities/php/visitor_ip.php', dataType: 'JSON', statusCode: { 404: function() { alert( "Page not found" ); }}, success: function(visitor_ip) { console.log(visitor_ip); } }); }); })(); The PHP <?php $referral_addr = $_SERVER['REMOTE_REFERER']; echo json_encode($referral_addr); ?> ERROR MESSAGE jquery.min.js:5 GET https://www.grammarcaptive.com/_utilities/php/visitor_ip.php 500 (Internal Server Error)send Is the $_SERVER variable not available in the moment of the AJAX? How do I otherwise make it available? Roddy
  5. BACKGROUND: I am querying a MySQL database with a Matomo GUI. The API is called imageGraph. The call to the API works, as I have produced the desired image by assigning the URL as the value of an href attribute of an HTML <a> element. When using this link to display the image the image appears on a new page with its own header. This is not the effect that I desire. My goal is to display the image within a <div> tag on a webpage. The code that is suppose to achieve this latter effect is provided below. The URL that fetches the data from the API is identical for both the link and the PHP processing page for the AJAX call provided below. The PHP (./practice.php) $url ='https://.../matomo/index.php ?module=API &method=ImageGraph.get &idSite=1 &apiModule=Referrers &apiAction=getReferrerType &token_auth= ... &period=day &date=2018-04-10,2018-05-09'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_exec($curl_request); curl_close($curl_request); The HTML <div id='referral_types'> <img src='' alt='Line Chart of Referral Types' /> </div> The Javascript $(document).ready(function() { $.ajax({ method: 'GET', url: "./practice.php", cache: false, contentType: 'image/png', success: function(response) { console.log(response); var graphic_src = response; $('#referral_types').find('img').attr('src', graphic_src); } }); }); EXPERIMENTATION: The console indicates that practice.php has been read, as it is filled with the kind of character nonsense typical of an image file. As the API permits an optional &format parameter I experimented with several including the following: AJAX PHP dataType JSON, &format=json dataType XML &format=xml (omit) &format=original The result was invariably the same. The ALT message with no image. Please advise. Roddy
  6. sgt_spike

    Content not showing

    I have a table pulling data from a database. Everything works getting the data to show in the table, however the content under the table isn't showing up. I'm using bootstrap 4.0 for layout, so I have rows and cols with the table being the third row and two other rows, not showing, under the 3rd row. I've moved one row about the table row and it show up, but put it back under the table and it disappears. I've ensured I have the right amount of div tags for each of the rows and cols. I'm at a loss
  7. Hi all, I have a php file to check a users input and it seems pretty straight-forward as far as logic goes, but the variable seems to be concatenating the "badEntry" onto its return value. I've been over it and over it and can't seem to see what's wrong. I originally had $userInput as the only return variable, but when I started having trouble I added the $toReturn variable to hopefully make it clear what I was doing wrong. Didn't help. I enter 'sakde12345' and I get that back with 'BadEntry' concatenated to it - looks like this - sakde12345BadEntry. My callback function is supposed to see if the return value is equal to 'BadEntry' and of course it isn't because it somehow includes the original input in front of it. It's returning this for either 'good' or 'bad' input. Can anyone figure out how I've miscoded or what? I also had a question about the debugger in chrome when I was running the js that called this php in the xmlhttprequest. The debugger traced thru everthing OK, but when it came to the 'onreadystatechange', it went to the 'xhr.open' line, jumped back to the onreadystatechange ( which became 1) but then it jumped to the requestheader line, then the .send line, then it jumped back to the js function that called the xhr request, then it jumped all the way back to the button in html that submitted the input. That kind of surprised me to see that - is the program just gathering information to proceed or something like that? I know it's kind of a weird question, but I'd like to understand what is going on. Thanx for any help, and I appreciate your patience!!! <?php $toReturn = ""; $userInput = ""; $chars = []; $i = 0; if ($_SERVER["REQUEST_METHOD"] == "POST"){ $userInput = $_POST["userID"]; // Get variable passed to xmlhttp call $userInput = test_input($userInput); // Run it thru easy data cleaner $userInput = strtolower($userInput); // change all to lower case $toReturn = $userInput; $chars = str_split($userInput); // split input into single characters if (strlen($userInput) != 10) { // is the input exactly 10 chars long $toReturn = "BadEntry"; } else { if (substr($userInput,0,3) != "sak") { // are the 1st 3 letters 'sak' $toReturn = "BadEntry"; } else { if (is_not_Char($chars[3]) || is_not_Char($chars[4])) { // are the 4th & 5th chars letters - name initials $toReturn = "BadEntry"; } else { for ($i = 5; $i < 10; $i++){ if (is_not_Numb($chars[$i])) { // are the last 5 chars Numbers $toReturn = "BadEntry"; } } } } } } echo $toReturn; function is_not_Char($examp){ $charBool = false; if ($examp < chr(97) || $examp > chr(122)) { // is it a lowercase letter - ascii 97 - 122 $charBool = true; } echo $charBool; } function is_not_Numb($examp){ $charBool = false; if ($examp < chr(48) || $examp > chr(57)) { // is it a number - ascii 48 - 57 ( 0 - 9 ) $charBool = true; } echo $charBool; } function test_input($data) { // standard data cleansing tools $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); echo $data; } ?>
  8. BACKGROUND: Working with Matomo has compelled me to dig deeper into the way that information gets passed over the internet. Up until now I have assumed that I can pass just about anything in a query string. In fact, this is exactly what I have been doing. What I am beginning to realize is that the PHP $_POST and $_GET variables have been doing work of which I was not aware. I have come to this conclusion with my new encounter of the encodeURI(), encodeURIComponent(), decodeURI(), and decodeURIComponent() functions. Indeed, I have read that no information can be passed in an HTTPRequest that is not in ASCII format. Is this true? QUESTION: Is it true that when working with PHP the values of PHP HTTPRequests are automatically URL encoded and URL decoded, and that when working with Javascript the same values must be manually encoded and decoded? Roddy
  9. Hi all, I have a couple of questions that popped up while studying php; really not questions, but I want to get some confirmation that my deductions are correct from what I've figured out. I was getting very confused over the differences in the object-oriented mysqli and the procedural mysqli and translating from one to the other. I think I like using OOps better The reference list on w3 only shows the procedural syntax so I wanted to make sure I was coming up with the correct OOps. Things like 'mysqli_query($conn,$sql)' becomes '$conn->query($sql)'. I could see that quite clearly in the tutorial, but some others get a little hazy like 'mysqli_free_result($result)' becomes '$result->free_result'. Do I have this correct? and is there a rule about changing from one to the other - like whatever the object of the function is goes first in the OOps syntax, or something. Now I noticed that when you check for a connection error the OOps syntax says '$conn->connect_err' while the procedural syntax is 'mysqli_connect_error()' with nothing in the parenthesies. Is that because the connection object hasn't actually been established yet? or some other mysterious reason. I also had a quick question about .php files in general. The w3 said that a file with php in it should end with .php, but when I do that the server won't execute it - so I change it to html and its OK. Now if I have a file with exclusively php code and I don't 'echo' any output, but only 'return' a value, do I still need to write the <!DOCTYPE> and other tags like <head>, etc. Or can I start the file with <?php and end it with ?>. Like I said , I think I have these things correctly in my mind, but if I'm not right I want to nip it in the bud and make sure I'm off on a good foundation. I've experimented with different ideas, but if it doesn't work, sometimes you can't figure out what you did wrong. Thank you so much for your input and answers!!
  10. Hello I'm facing a problem I cant really solve. I want to place a backlink in the shape of either a textlink or an img banner outside my own server. (for instance inside an iframe) I want to be able to track download impressions and referrer clicks. Can this be done with php or not? It seems technically not possible to place php on someone else's server. What would you recommend?
  11. Hallo, Can anybody help for this question. I have changed my computer. And now my browser (google chrome) can not read php-files from my computer. I have installed PHP from XAMPP. What may be the reason for this?
  12. honkmaster

    CURDATE() not working for next month

    Hi I have a query that returns the count of entries based on CURDATE(), it works for any dat in this month (April) but does not work for next month (May). I think it is something to do with CURDATE()+3 returns 2018-04-31 which should be 2018-05-01 This Works as Date is in April SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed' AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE() This does not work as in May SELECT COUNT(Machine) FROM production WHERE Status = 'Confirmed' AND DATE(FROM_UNIXTIME(production.Required)) = CURDATE()+3
  13. i want to build a bar chart with chartJS and database mysql with two different query, but bar chart not showing. can anyone help me to correct the code? this my query and javascript: <?php $a = mysqli_query("select count(a) as total1 from tbl"); $b = mysqli_query("select count(b) as total2 from tbl"); ?> <body> <div> <canvas id="chart"></canvas> </div> <script> var ctx = document.getElementById("chart"); var chartdata = { labels: 'CHART', datasets: [{ label: "A", data: [<?php while ($data1 = mysqli_fetch_array($a)) {echo '"''.$data1['total1'].'",';}?>], backgroundColor: "#000000" },{ data: [<?php while ($data2 = mysqli_fetch_array($b)) {echo '"''.$data2['total2'].'",';}?>], backgroundColor: "#ffffff" }] }; var chart = new Chart(ctx, { type: 'bar', data: chartdata }); </script> </body>
  14. Sigmahokies

    Flexible in array for table in the Database

    Hi everyone, I am trying to set up the flexible with array, like set up the array by count the columns in tables in the Database, so I am still figure how to create variable word through loop to allow equalized from $_post as if $_post appear in two or three or four...I figured out to set up the $_post in loop, but I haven't find a way to have create new variable to equalized with $_post in loop in same time. here my code <!doctype html> <html> <head> <title>Add name and number</title> <link href="defaultdatabase.css" rel="stylesheet" type="text/css"> </head> <h2>Add any DSDJ information to database</h2> <?php require ("require2.php"); $sql = "show tables from NewDSDJ"; $list = mysqli_query($GaryDB, $sql); while ($row = mysqli_fetch_array($list)) { $table[] = $row[0]; $option = ''; foreach ($table as $rows) { $option .= "<option value='{$rows}'>{$rows}</option>"; } } ?> <form action="addname.php" method="post"> <table> <tr><th>Select the table</td><td> <select name="subject"> <?php echo $option; ?> </select></td><td><input type="submit" name="selected" value="select"></td></tr> </table> </form> <form> <table> <?php if (isset($_POST['selected'])) { $selected = $_POST['subject']; $column = "select column_name from information_schema.columns where table_name = '" . $selected . "'"; $list5 = mysqli_query($GaryDB, $column); while ($array = mysqli_fetch_array($list5)) { $input = ''; foreach ($array as $row5) { $input = "<tr><td>{$row5}:</td><td colspan='2'><input type='text' name='label[]'></td></tr>"; } echo $input; } if (isset($_POST['insert'])) { foreach ($array as $row6) { $ins = "{$row6},"; } for ($i = 0; $i < count($array); $i++) { $label = $_POST['label']; } echo $label; $insert = "insert into " . $selected . " (" . $ins . ") values (" . $label . ")"; mysqli_query($GaryDB, $insert) or die("Could not insert"); } }echo "<tr><td><input type='submit' name='insert'></td></tr>"; mysqli_close($GaryDB); ?> </table> </form> </html> Look at above of $insert, that is one I haven't figure how to create variable word to get data from name in form in HTML. Can you help? Thanks, Gary Taylor
  15. emcy

    php NOT words?

    Hi, I am working on a simple login for just 1 person.. me .. to be able to update my blog online. I would like to have the login button on the blog page itself. I currently have it set up as a modal. I have the database setup for 4 columns - ID, date, title, content and signedby I have the form page set up as well (blog.php), and the database access dbconfig.php file is written also. 1. - wrote up the modal button so that when I click on the login/submit button it should call up pswchecking.php to verify that the username and password are me only, and that if it is true, then it will pop up the blog entry page which then enters the new entries into the database in mysqli. (how do I write pswchecking.php? - I looked at Mysqli code in w3schools, and php and ajax. I could maybe do it as a php/ajax file but then the text file can be found by a search on google, how do I hide it? So then I thought maybe to do a database with just one user in it.. me that felt like overkill.. not sure.. ideas? After that, I want to automatically be able to post the new blog entries from the database to the blog.php page automatically. I would also like it sorted by year and month links so they don't get all the records downloaded, and it only shows the latest post. To say the least, I would not be posting if it worked like a charm . It doesn't work and I get error messages... current code I have is as such: 1. blog.php page with a login modal button . <!-- Modal Content --> <?php //keep this in here to display all the errors on debugging ini_set('display_errors', 1); error_reporting(E_ALL); // SECTION A // define the connection info // got this info from 1and1.com directly include('blogdbConfig.php'); // where blogdbConfig.php is //<?php // got this info from 1and1.com directly //$host_name = "dbnumber.db.1and1.com"; // $user_name = "dbonumber"; // $password = "password"; // $database = "dbnumber"; // Create connection using the mysqli procedural format //$connect = mysqli_connect($host_name, $user_name, $password, $database); // Check connection // if (!$connect) { // die("Connection failed: " . mysqli_connect_error()); // } // ?> //***********NOW THAT IT'S CONNECTED TO THE DATABASE I WANT IT TO POP UP A PAGE CALLED blogentriespage.php SO I CAN MAKE A NEW DATABASE ENTRY. //DO I USE AN INCLUDE STATMENT HERE? SUCH AS THE FOLLOWING, AND HOW DO I PUT IT ON A POP-UP PAGE? //<?php //include('blogentriespage.php'); //?> // where blogentries.php is: // <?php //keep this in here to display all the errors on debugging // ini_set('display_errors', 1); // error_reporting(E_ALL); // include('blogdbConfig.php'); // $connect = mysqli_connect($host_name, $user_name, $password, $database); // if (!$connect) { // die("Connection failed: " . mysqli_connect_error()); // } // function test_input($data) { // $data = trim($data); // $data = stripslashes($data); // $data = htmlspecialchars($data); // return $data; // } // $dateErr = $titleErr = $contentErr = $signedbyErr = ""; // $date = $title = $content = $signedby = ""; // if ($_SERVER["REQUEST_METHOD"] == "POST") { // $passed = true; // if (empty($_POST["date"])) { // $dateErr = "Please enter a date in the format of monthname date, full year"; // $passed = false; // } else { // $date = test_input($_POST["date"]); // } // if (empty($_POST["title"])) { // $titleErr = "Title is required"; // $passed = false; // } else { // $title = test_input($_POST["title"]); // if (!preg_match("/^[a-zA-Z ]*$/",$title)) { // $passed = false; // $titleErr = "Only letters and white space allowed"; // } // } // if (empty($_POST["content"])) { // $contentErr = "Content is required"; // $passed = false; // } else { // $content = test_input($_POST["content"]); // } // if (empty($_POST["signedby"])) { // $signedbyErr = "Signed by is required"; // $passed = false; // } else { // $signedby = test_input($_POST["signedby"]); // if (!preg_match("/^[a-zA-Z ]*$/",$signedby)) { // $passed = false; // $signedbyErr = "Only letters and white space allowed"; // } // } // if ($passed) { // $mysqli = "INSERT INTO xmasblogentries (date, title, content, signedby) VALUES ('$date','$title','$content','$signedby')"; // if (mysqli_query($connect, $mysqli)) { // echo "New record created successfully"; // } else { // echo "Error: " . $mysqli . "<br>" . mysqli_error($connect); // } // $email = "info@me.com"; // $emailSubject = "A new blog entry was just received in the database"; // $headers = "From:$signedby\r\n"; // $headers = "Content-type: text/html\r\n"; // $body = <<<EOD // <br><hr><br> // Date : $date <br> // Title : $title <br> // Content : $content <br> // Signed By : $signedby <br> // EOD; // $success = mail($email, $emailSubject, $body, $headers); // echo "<h2>Thank you your new blog entry was received successfully. Here is a copy of what you wrote:</h2>"; // echo "Date: " . $date . "<br>"; // echo "Title: " . $title . "<br>"; // echo "Content: " . $content . "<br>"; // echo "Signed By: " . $signedby . "<br>"; // $date = $title = $content = $signedby = ""; // } // } // ?> // <p><span class="error">* required field.</span></p> // <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" enctype="application/x-www-form-urlencoded"> // Date:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Date" name="date" value="<?php echo $date; ?>"><span class="error">* <?php echo $dateErr; ?></span><br> // Title:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Title" required name="title" value="<?php echo $title; ?>"><span class="error">* <?php echo $titleErr; ?></span><br> // Content:<textarea placeholder="Content" required name="content" rows="30" cols="40" value="<?php echo $content; ?>"></textarea><span class="error">* <?php echo $contentErr; ?></span><br> // Signed By:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Signed By" required name="signedby" value="<?php echo $signedby; ?>"><span class="error">* <?php echo $signedbyErr; ?></span><br> // <input class="w3-input w3-padding-16 w3-border" type="datetime-local" required name="date" value="2017-11-16T20:00"> // <br> // <button class="w3-button w3-black"><input type="submit" name="submit" value="Submit"></button> // </form> // <?php // mysqli_close($connect); // ?> // </div> //SECTION C // Define the connection and then connect $connect = mysqli_connect($host_name, $user_name, $password, $database); // this is where the debugging portion ends // set all the fields on the new database record to empty initially to reset it from the previous entry // SECTION B // check the connection if (!$connect) { die("Connection failed: " . mysqli_connect_error()); } // SECTION C //This tells the server what to do with the entry info when it gets to the SECTION D of this php page // test again and strip the user info of characters I don't want function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } // set all the fields on the new database record to empty initially to reset it from the previous user (do I need to autoincrement here somewhere? Maybe my database settings are wrong?) $dateErr = $titleErr = $contentErr = $signedbyErr = ""; $date = $title = $content = $signedby = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { // if connected to the server successfully and it requests info or is ready to receive the info.... $passed = true; // } else { $passed = false; } // then start working on the user's info to clean it up and make sure all the fields have been filled in if (empty($_POST["date"])) { $dateErr = "Please enter a date in the format of monthname date, full year"; $passed = false; } else { $date = test_input($_POST["date"]); } if (empty($_POST["title"])) { $titleErr = "Title is required"; $passed = false; } else { $title = test_input($_POST["title"]); if (!preg_match("/^[a-zA-Z ]*$/",$title)) { $passed = false; $titleErr = "Only letters and white space allowed"; } } if (empty($_POST["content"])) { $contentErr = "Content is required"; $passed = false; } else { $content = test_input($_POST["content"]); } if (empty($_POST["signedby"])) { $signedbyErr = "Signed by is required"; $passed = false; } else { $signedby = test_input($_POST["signedby"]); if (!preg_match("/^[a-zA-Z ]*$/",$signedby)) { $passed = false; $signedbyErr = "Only letters and white space allowed"; } } if ($passed) { //SECTION E // define what $mysqli is made up of (taken from the fields in the html form code above) $stmt = $mysqli->prepare("INSERT INTO xmasblogentries (date, title, content, signedby) VALUES (':date',':title',':content',':signedby')"); $stmt->bindParam(':date', $txtdate); $stmt->bindParam(':title', $txttitle); $stmt->bindParam(':content', $txtcontent); $stmt->bindParam(':signedby', $txtsignedby); $stmt->execute(); //SECTION F // Checking the connection and verifying the user's information/$mysqli (which was defined above) has been entered into the new record in the database, then it gives a success message if (mysqli_query($connect, $mysqli)) { echo "New record created successfully"; } else { echo "Error: " . $mysqli . "<br>" . mysqli_error($connect); } // SECTION G // define what $email, and $email Subject is made up of for when it sends an email to me to let me know someone just posted something. $email = "info@me.com"; $emailSubject = "A new blog entry was just received in the database"; // define what the headers of the email should say $headers = "From:$signedby\r\n"; $headers = "Content-type: text/html\r\n"; // define what the body of the email should say and look like $body = <<<EOD <br><hr><br> Date : $date <br> Title : $title <br> Content : $content <br> Signed By : $signedby <br> EOD; $success = mail($email, $emailSubject, $body, $headers); // SECTION I // on this same user's page on his computer in the browser window, next, print on screen a copy of what the user entered above echo "<h2>Thank you your new blog entry was received successfully. Here is a copy of what you wrote:</h2>"; echo "Date: " . $date . "<br>"; echo "Title: " . $title . "<br>"; echo "Content: " . $content . "<br>"; echo "Signed By: " . $signedby . "<br>"; $date = $title = $content = $signedby = ""; } } ?> <form class="modal-content animate" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" enctype="application/x-www-form-urlencoded">> <div class="imgcontainer"> <img src="http://www.me.com/pagepieces/images/me.png" alt="Avatar" width="150" height="100" class="avatar"> </div> <div class="container"> <label for="uname"><b>Username</b></label> <input type="text" placeholder="Enter Username" name="uname" required> <label for="psw"><b>Password</b></label> <input type="password" placeholder="Enter Password" name="psw" required> <button type="submit" name="submit" value="Submit">Login</button> </div> <div class="container" style="background-color:#f1f1f1"> <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Cancel</button> </div> </form> <?php mysqli_close($connect); ?> </div> <script> // Get the modal var modal = document.getElementById('id01'); // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } } </script> 2. I would like to make it so that when I click on the "submit" button, that it first checks to see if I have entered the correct user name and password info (do I need to make a php file such as pswchecking.php or do this in a new database for only 1 user name?) and that if it isn't me, then it sends an error message - This is what I have written up from my mixed limited understanding of javascript, php, html, etc... (note I am also getting an error in Dreamweaver on the "die("you are NOT Me You cannot access this database"; line - why? Also.. where to place the "include" for this php page? Does it go on the modal before or after the submit button? <?php $user_name = "me"; $password = "mysetpasword"; // Check connection if (!$user_name . !$password) { die("You are NOT Me You cannot access this database"; } ?> 3. Then, if it is me, to give a success message <?php $user_name = "myword"; $password = "mypasword"; // Check connection if (!$user_name, !$password) { die("You are NOT Me! You cannot access this database " . mysqli_connect_error()); } } else { echo "Hi Me! Welcome Back! "; } ?> 4. And to pop up the blog.php page to enter a new blog entry on (how do I make it be a pop window? if its in the middle of the coding?) <?php $user_name = "myword"; $password = "mypasword"; // Check connection if (!$user_name, !$password) { die("You are NOT Me! You cannot access this database " . mysqli_connect_error()); } } else { echo "Hi Me! Welcome Back! " . include('blogentrypage.php'); } ?> 5. This is the blog entry page <?php //keep this in here to display all the errors on debugging ini_set('display_errors', 1); error_reporting(E_ALL); // SECTION A // define the connection info // got this info from 1and1.com directly include('blogdbConfig.php'); // Define the connection and then connect $connect = mysqli_connect($host_name, $user_name, $password, $database); // this is where the debugging portion ends // SECTION B // check the connection if (!$connect) { die("Connection failed: " . mysqli_connect_error()); } // SECTION C // test again and strip the user info of characters I don't want function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } // set all the fields on the new database record to empty initially to reset it from the previous entry $dateErr = $titleErr = $contentErr = $signedbyErr = ""; $date = $title = $content = $signedby = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { // if connected to the server successfully and it requests info or is ready to receive the info.... $passed = true; // } else { $passed = false; } // then start working on the entry info to clean it up and make sure all the fields have been filled in if (empty($_POST["date"])) { $dateErr = "Please enter a date in the format of monthname date, full year"; $passed = false; } else { $date = test_input($_POST["date"]); } if (empty($_POST["title"])) { $titleErr = "Title is required"; $passed = false; } else { $title = test_input($_POST["title"]); if (!preg_match("/^[a-zA-Z ]*$/",$title)) { $passed = false; $titleErr = "Only letters and white space allowed"; } } if (empty($_POST["content"])) { $contentErr = "Content is required"; $passed = false; } else { $content = test_input($_POST["content"]); } if (empty($_POST["signedby"])) { $signedbyErr = "Signed by is required"; $passed = false; } else { $signedby = test_input($_POST["signedby"]); if (!preg_match("/^[a-zA-Z ]*$/",$signedby)) { $passed = false; $signedbyErr = "Only letters and white space allowed"; } } if ($passed) { //SECTION E // define what $mysqli is made up of (taken from the fields in the html form code below) $mysqli = "INSERT INTO blogentries (date, title, content, signedby) VALUES ('$date','$title','$content','$signedby')"; //SECTION F // Checking the connection and verifying the user's information/$mysqli (which was defined above) has been entered into the new record in the database, then it gives a success message if (mysqli_query($connect, $mysqli)) { echo "New record created successfully"; } else { echo "Error: " . $mysqli . "<br>" . mysqli_error($connect); } // SECTION G // define what $email, and $email Subject is made up of for when it sends an email to me to let me know I just posted something. $email = "info@me.com"; $emailSubject = "A new blog entry was just received in the database"; // define what the headers of the email should say $headers = "From:$signedby\r\n"; $headers = "Content-type: text/html\r\n"; // define what the body of the email should say and look like $body = <<<EOD <br><hr><br> Date : $date <br> Title : $title <br> Content : $content <br> Signed By : $signedby <br> EOD; // SECTION H // define the action to take upon success of a new record having been created - i.e. mail it with the email info, email subject, body, and headers from the above definitions, to my email address $success = mail($email, $emailSubject, $body, $headers); // SECTION I // on this same page on the computer in the browser window, next, print on screen a copy of what was entered echo "<h2>Thank you your new blog entry was received successfully. Here is a copy of what you wrote:</h2>"; echo "Date: " . $date . "<br>"; echo "Title: " . $title . "<br>"; echo "Content: " . $content . "<br>"; echo "Signed By: " . $signedby . "<br>"; // SECTION J // when everything has been done, close the database connection $date = $title = $content = $signedby = ""; } } ?> <p><span class="error">* required field.</span></p> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" enctype="application/x-www-form-urlencoded"> Date:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Date" name="date" value="<?php echo $date; ?>"><span class="error">* <?php echo $dateErr; ?></span><br> Title:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Title" required name="title" value="<?php echo $title; ?>"><span class="error">* <?php echo $titleErr; ?></span><br> Content:<textarea placeholder="Content" required name="content" rows="30" cols="40" value="<?php echo $content; ?>"></textarea><span class="error">* <?php echo $contentErr; ?></span><br> Signed By:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Signed By" required name="signedby" value="<?php echo $signedby; ?>"><span class="error">* <?php echo $signedbyErr; ?></span><br> <input class="w3-input w3-padding-16 w3-border" type="datetime-local" required name="date" value="2017-11-16T20:00"> <!--- PLACEHOLDER Not allowed on this type ABOVE--> <br> <button class="w3-button w3-black"><input type="submit" name="submit" value="Submit"></button> </form> <?php mysqli_close($connect); ?> 6. Next, when I have finished entering the information for the new entry, and click submit - it goes to a Config.php file to access the database and put the info into it <?php // got this info from 1and1.com directly $host_name = "me.db.1and1.com"; $user_name = "medatabaseusername"; $password = "mydatabasepsassword"; $database = "mydatabase"; // Create connection using the mysqli procedural format $connect = mysqli_connect($host_name, $user_name, $password, $database); // Check connection if (!$connect) { die("Connection failed: " . mysqli_connect_error()); } ?> I have the entry page setup to send me a confirmation email with the new entry info. The final step is to add the information for the new posting only, on the blog.php page, as well as links to years and months for all the other postings , so not all the entries are shown at once. <?php //keep this in here to display all the errors on debugging ini_set('display_errors', 1); error_reporting(E_ALL); // SECTION A // define the connection info // got this info from 1and1.com directly include('blogdbConfig.php'); // Define the connection and then connect $connect = mysqli_connect($host_name, $user_name, $password, $database); // this is where the debugging portion ends // SECTION B // check the connection if (!$connect) { die("Connection failed: " . mysqli_connect_error()); } // SECTION C // test again and strip the user info of characters I don't want function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } // set all the fields on the new database record to empty initially to reset it from the previous entry $dateErr = $titleErr = $contentErr = $signedbyErr = ""; $date = $title = $content = $signedby = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { // if connected to the server successfully and it requests info or is ready to receive the info.... $passed = true; // } else { $passed = false; } // then start working on the entry info to clean it up and make sure all the fields have been filled in if (empty($_POST["date"])) { $dateErr = "Please enter a date in the format of monthname date, full year"; $passed = false; } else { $date = test_input($_POST["date"]); } if (empty($_POST["title"])) { $titleErr = "Title is required"; $passed = false; } else { $title = test_input($_POST["title"]); if (!preg_match("/^[a-zA-Z ]*$/",$title)) { $passed = false; $titleErr = "Only letters and white space allowed"; } } if (empty($_POST["content"])) { $contentErr = "Content is required"; $passed = false; } else { $content = test_input($_POST["content"]); } if (empty($_POST["signedby"])) { $signedbyErr = "Signed by is required"; $passed = false; } else { $signedby = test_input($_POST["signedby"]); if (!preg_match("/^[a-zA-Z ]*$/",$signedby)) { $passed = false; $signedbyErr = "Only letters and white space allowed"; } } if ($passed) { //SECTION E // define what $mysqli is made up of (taken from the fields in the html form code below) $mysqli = "INSERT INTO blogentries (date, title, content, signedby) VALUES ('$date','$title','$content','$signedby')"; //SECTION F // Checking the connection and verifying the user's information/$mysqli (which was defined above) has been entered into the new record in the database, then it gives a success message if (mysqli_query($connect, $mysqli)) { echo "New record created successfully"; } else { echo "Error: " . $mysqli . "<br>" . mysqli_error($connect); } // SECTION G // define what $email, and $email Subject is made up of for when it sends an email to me to let me know I just posted something. $email = "info@me.com"; $emailSubject = "A new blog entry was just received in the database"; // define what the headers of the email should say $headers = "From:$signedby\r\n"; $headers = "Content-type: text/html\r\n"; // define what the body of the email should say and look like $body = <<<EOD <br><hr><br> Date : $date <br> Title : $title <br> Content : $content <br> Signed By : $signedby <br> EOD; // SECTION H // define the action to take upon success of a new record having been created - i.e. mail it with the email info, email subject, body, and headers from the above definitions, to my email address $success = mail($email, $emailSubject, $body, $headers); // SECTION I // setup a new link on the blog page for the category under which it falls (i.e. year/month/date) //i.e if a new database record was created, then post the new link on the blog page by category under year and month and date ( so it needs to be sorted in order), and show only the fresh content via an "echo" command? //HOW!?!?!???! // SECTION J // when everything has been done, close the database connection $date = $title = $content = $signedby = ""; } } ?> <p><span class="error">* required field.</span></p> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" enctype="application/x-www-form-urlencoded"> Date:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Date" name="date" value="<?php echo $date; ?>"><span class="error">* <?php echo $dateErr; ?></span><br> Title:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Title" required name="title" value="<?php echo $title; ?>"><span class="error">* <?php echo $titleErr; ?></span><br> Content:<textarea placeholder="Content" required name="content" rows="30" cols="40" value="<?php echo $content; ?>"></textarea><span class="error">* <?php echo $contentErr; ?></span><br> Signed By:<input class="w3-input w3-padding-16 w3-border" type="text" placeholder="Signed By" required name="signedby" value="<?php echo $signedby; ?>"><span class="error">* <?php echo $signedbyErr; ?></span><br> <input class="w3-input w3-padding-16 w3-border" type="datetime-local" required name="date" value="2017-11-16T20:00"> <!--- PLACEHOLDER Not allowed on this type ABOVE--> <br> <button class="w3-button w3-black"><input type="submit" name="submit" value="Submit"></button> </form> <?php mysqli_close($connect); ?> where blogsortedlinks.php is used to sort the information before posting it on the blog.php page: <?php //keep this in here to display all the errors on debugging ini_set('display_errors', 1); error_reporting(E_ALL); // SECTION A // define the connection info // got this info from 1and1.com directly include('blogdbConfig.php'); // Define the connection and then connect $connect = mysqli_connect($host_name, $user_name, $password, $database); // this is where the debugging portion ends /// set all the fields on the new database record to empty initially to reset it from the previous user (do I need to autoincrement here somewhere? Maybe my database settings are wrong?) // SECTION B // check the connection if (!$connect) { die("Connection failed: " . mysqli_connect_error()); } // SECTION C //This tells the server what to do with the user's info when it gets to the SECTION D of this php page (I suspect this should be after the SECTION D but then SECTION E of defining mysqli will have to be moved down further as well) // test again and strip the user info of characters I don't want function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } // set all the fields on the new database record to empty initially to reset it from the previous user (do I need to autoincrement here somewhere? Maybe my database settings are wrong?) $dateErr = $titleErr = $contentErr = $signedbyErr = ""; $date = $title = $content = $signedby = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { // if connected to the server successfully and it requests info or is ready to receive the info.... $passed = true; // } else { $passed = false; } if ($passed) { // I have a MySQL database with which I'm dynamically populating a web page. I'm building a MySQL query that fetches some dates stored in a table called blogentries that I can later echo out on the blog page with PHP. The columns in that table are id, date, title, content, and signedby. I want the user to be able to sort dates and titles alphabetically, by date (low-high) etc by clicking the relevant links on the page. This is what I've written so far: // Run a SELECT query to get all the dates that are stored in the database // By default, if no sorting URL variable is fed onto the page, then the SQL query becomes order by id. // The first time you land on the blog page as plain blog.php, not blog.php?=variable, this is the query that's used $mysqli = mysqli_query($connect,"SELECT * FROM blogentries ORDER BY date DESC"); // If the user chooses to sort the dates in a different way, then an HTML link will set a PHP variable onto this blog page // We will check for that variable and change the SQL query to sort the dates in a different way if (isset($_GET['sortby'])) { // Capture that in a variable by that name $sortby == $_GET['sortby']; // Now to change the SQL query based on the sorting the user chose (date high to low, low to high, alphabetical and latest first) if ($sortby == 'datehilo') { $mysqli = mysqli_query($connect,"SELECT * FROM date ORDER BY title DESC"); } elseif ($sortby = 'datelohi') { $mysqli == mysqli_query($connect,"SELECT * FROM date ORDER BY title ASC"); } elseif ($sortby = 'title') { $mysqli == mysqli_query($connect,"SELECT * FROM date ORDER BY title"); } } <p><a href="blog.php?sortby=datehilo">Date (Highest-Lowest)</a></p> <p><a href="blog.php?sortby=datelohi">Date (Lowest-Highest)</a></p> <p><a href="blog.php?sortby=title">Alphabetical</a></p> ?> sortedlinks.php is: <?php ini_set('display_errors', 1); error_reporting(E_ALL); include('blogdbConfig.php'); $connect = mysqli_connect($host_name, $user_name, $password, $database); if (!$connect) { die("Connection failed: " . mysqli_connect_error()); } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $dateErr = $titleErr = $contentErr = $signedbyErr = ""; $date = $title = $content = $signedby = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { $passed = true; // } else { $passed = false; } if ($passed) { $mysqli = mysqli_query($connect,"SELECT * FROM blogentries ORDER BY date DESC"); // I copied the folowing code from somewhere else and am wondering if I need to make abother php page or something that identifies the variables sortby, datehilo, datelohi, title - seems to me this coudl just be done on the mysqli database itself ? // If the user chooses to sort the dates in a different way, then an HTML link will set a PHP variable onto this blog page // We will check for that variable and change the SQL query to sort the dates in a different way if (isset($_GET['sortby'])) { // Capture that in a variable by that name $sortby == $_GET['sortby']; // Now to change the SQL query based on the sorting the user chose (date high to low, low to high, alphabetical and latest first) if ($sortby == 'datehilo') { $mysqli = mysqli_query($connect,"SELECT * FROM date ORDER BY title DESC"); } elseif ($sortby = 'datelohi') { $mysqli == mysqli_query($connect,"SELECT * FROM date ORDER BY title ASC"); } elseif ($sortby = 'title') { $mysqli == mysqli_query($connect,"SELECT * FROM date ORDER BY title"); } } include('blogentryretrieval.php'); <p><a href="blog.php?sortby=datehilo">Date (Highest-Lowest)</a></p> <p><a href="blog.php?sortby=datelohi">Date (Lowest-Highest)</a></p> <p><a href="blog.php?sortby=title">Alphabetical</a></p> ?> and finally blogentryretrieval.php <?php // got this info from 1and1.com directly $host_name = "dbnumber.db.1and1.com"; $user_name = "dbonumber"; $password = "password"; $database = "dbnumber"; // Create connection using the mysqli procedural format $connect = mysqli_connect($host_name, $user_name, $password, $database); // Check connection if (!$connect) { die("Connection failed: " . mysqli_connect_error()); } $mysqli = "SELECT date, title, content, signedby FROM blogentries"; $result = $connect->query($mysqli); if ($result->num_rows > 0) { echo "<table><tr><th>Date</th><th>Title</th><th>Content</th><th>Written by:</th></tr>"; // output data of each row while($row = $result->fetch_assoc()) { echo "<tr><td>" . $row["date"]. "</td><td>" . $row["title"]. "</td><td> " . $row["content"]. "</td><td>" . $row["signedby"]. "</td></tr>"; } echo "</table>"; } else { echo "0 results"; } $connect->close(); ?> The error messages I am getting are as follows: on the blog.php page when I call it up initially it says this: Warning: include(blogsortedlinks): failed to open stream: No such file or directory in /homepages/42/htdocs/blog.php on line 375Warning: include(): Failed opening 'blogsortedlinks' for inclusion (include_path='.:/usr/lib/php5.6') in /homepages/42/htdocs/blog.php on line 375Date: Notice: Undefined index: date in /homepages/42/htdocs/blog.php on line 378Title: Notice: Undefined index: title in /homepages/42/htdocs/blog.php on line 379Content: Notice: Undefined index: content in /homepages/42/htdocs/blog.php on line 380Author: Notice: Undefined index: signedby in /homepages/42/htdocs/blog.php on line 381 When I click on the login button.. it calls up the modal fine....but.. it disappears when I click on submit and doesn't do anything.... I also don't know where to put my username and password in a database or on a separate php file to sore it permanently so the modal can call on it to verify I am the right person ....ideas? Thanks B
  16. honkmaster

    Calculate Total hours and Mins (over 24)

    Hi I need to display total hours and mins as this example "35 Hrs 23 Mins", issue I'm having is after 24 it goes back to zero I'm storing the time as follows 127380 (seconds) I should get 35:23 but I'm getting 59:23 ??? Any ideas would help $date = '127380'; $minsec = gmdate("i:s", $date); $hours = gmdate("d", $date)*24 + gmdate("H", $date); echo $time = $hours . ':' . $minsec;
  17. I have a form written using HTML5 and CSS3, final validation is performed on submit with JavaScript. Then, the form will be sent to the server, most likely using PHP's mail() function. I don't recall how to include two items such as these in a form's action="...", I'd deeply appreciate if someone could refresh my memory! Thank you
  18. iwato

    Error 500 - Probable Causes

    BACKGROUND: The following code was copied from the Grammar Captive mainpage where it performs just as it was designed to perform. Sadly, however, it fails on my local test server. The error log to which the file points indicates nothing and the data is properly entered into the data base. Further, although the PHPMailerAutoload.php class loads properly, the mail does not get sent and message is produced. Finally, the Javascript Console claims the following: "Failed to load resource: the server responded with a status of 500 (Internal Server Error)". And, the resource that it names is the very same listed below. I checked the confirmation_mail.php file and discovered that two of the links were not using secure protocol and adjusted these. Now, it worked before I upgraded to PHP 5.6.3, but for some reason it does not work now. <?php ini_set('display_errors', 0); ini_set('error_log', '../../../error.log'); ini_set('log_errors', 1); error_reporting(E_ALL); require_once './php_mailer/PHPMailerAutoload.php'; $name = $email = $location = $language_level = $language = $personal = $msg = '' ; if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (!empty($_POST['name']) && !empty($_POST['email']) && !empty($_POST['location']) && !empty($_POST['language']) && !empty($_POST['language_level']) && isset($_POST['personal'])) { $name = filter_var($_POST['name'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); $email = filter_var($_POST['email'], FILTER_VALIDATE_EMAIL, FILTER_SANITIZE_EMAIL); $location = filter_var($_POST['location'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); $language_level = filter_var($_POST['language_level'], FILTER_SANITIZE_NUMBER_INT, FILTER_VALIDATE_INT); $language = filter_var($_POST['language'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); $personal = filter_var($_POST['personal'], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); include_once('./classes/class.lunarpages.php'); $lunarpages = new Lunarpages(); $mysqli_obj = $lunarpages->get_mysqli_obj(); function random_password() { $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!_!_!_!_!_!_!_'; $pass = array(); $alphaLength = strlen($alphabet) - 1; for ($i = 0; $i < 8; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); } $password = random_password(); $hash = password_hash($password, PASSWORD_DEFAULT); $active = 0; $newsletter = 1; $webinar = 1; $tbl_name = 'thege0_grammarcaptive.captive_roster'; $sql_1 = "INSERT INTO $tbl_name (user_name, language, email_address, location, language_level, personal, psw_hash, active, newsletter, webinar) VALUES ('" . $name . "','" . $language . "','" . $email . "','" . $location . "','" . $language_level . "','" . $personal . "','" . $hash . "','" . $active . "','" . $newsletter . "','" . $webinar . "')"; $mysqli_obj->query($sql_1); $mail = new PHPMailer; $mail->CharSet = 'UTF-8'; $mail->isSMTP(); $mail->SMTPDebug = 0; $mail->Debugoutput = 'html'; $mail->Host = "baha.lunarbreeze.com"; $mail->Port = 587; $mail->SMTPAuth = true; $mail->Username = "webinar@grammarcaptive.com"; $mail->Password = "..."; $mail->setFrom('webiniar@grammarcaptive.com', 'Grammar Captive'); $mail->addReplyTo('admin@grammarcaptive.com', 'Grammar Captive Administration'); $mail->addAddress($email, $name); $mail->Subject = 'Account Verification'; $html_message = file_get_contents('../../confirmation_mail.php'); $html_message = str_replace('%name%', $name, $html_message); $html_message = str_replace('%email%', $email, $html_message); $html_message = str_replace('%hash%', $hash, $html_message); $html_message = str_replace('%language%', $language, $html_message); $mail->msgHTML($html_message); $alt_message = "Congratulations, $name! You have successfully created a Grammar Captive account./n/r Please click on the link below to verify that you are the owner of the account and to receive your first edition of Seven Gates, the Grammar Captive weekly newsletter. You will be notified by email as soon as a date and time have been set for your first free webinar./n/r http://www.grammarcaptive.com/_utilities/php/email_verify.php?name=$name&email=$email&hash=$hash&language=$language&letter_no=1"; $mail->AltBody = $alt_message; if (!$mail->send()) { $msg = $mail->ErrorInfo; } else { $msg = "<h1 style = 'text-align: center;color: #4E7F4E;font-size: 3em;font-weight: bold;font-family: Bradley Hand, cursive;margin: -1em, auto;vertical-align: bottom;'>Free Webinar</h1><p style='text-align: center; margin-top: -1.2em; font-size: 0.9em;'>Including the first edition of the Seven Gates weekly newsletter!</p><h2>Congratulations, <span style='font-family: Bradley Hand, cursive;font-size:1.4em;color:#4E7F4E;'>$name</span>!</h2><p style='text-align:left;'>Your information has been securely sent using SMTP protocol and a TSL/SSL security layer.</p><p>Please look for a verification email in your email inbox and click on the link provided. This will insure that you are the person who submitted the data.</p><p>You will receive an email in your inbox as soon as a date and time for the free webinar has been scheduled.</p><p>Episode No. 1 of the Seven Gates newsletter will arrive in your email inbox after you have confirmed your identity.</p><p><span style='color:#4E7F4E;font-weight:bold;'>CAUTION: </span>Sometimes the verification mail will be redirected to a user's junk box. Do not treat it as junk, for without verification no newsletter can be received!</p><p>In addition, you may have to adjust your email software to insure that future email from Grammar Captive arrives in your inbox.</p><p style='text-align:left;'><span style='color:#4E7F4E;font-weight:bold;'>SECURE STORAGE:</span> Your information is stored on the Lunarpages webserver in Orange, California. If you have any questions about the safety of your data, please read under the headings <em>Other/Internet Security</em> and <em>Other/Legal Privacy</em> in the Grammar Captive navigation bar on your left. Alternatively, you may email the Grammar Captive webmaster at <a href='mailto:admin@grammarcaptive.com?subject=Grammar%20Captive%20Webmaster%20-%20Question%20About%20Internet%20Security' title='The Grammar Captive webmaster' target='_blank'>admin@grammarcaptive.com</a>.</p><p>Thank you for your cooperation!</p>"; } echo $msg; } } ?> Any ideas? Roddy
  19. rootKID

    search query done... i think?

    Hello W3S - me again... So i have this little peace of code: if( isset($_POST['FORMNAME_submit_search']) ) { $qur = ""; @$SearchKeywords = mysqli_real_escape_string($dblink, $_POST['FORMNAME_SogProfilBar_Keywords']); // Search Bar Profil Keywords @$MinAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinAlder']); // Minimum Alder @$MaxAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxAlder']); // Maximum Alder @$Landsdel = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Landsdel']); // Landsdel @$Kon = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kon']); // Køn @$MinHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinHojde']); // Minimum Højde @$MaxHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxHojde']); // Maximum Højde @$Etnicitet = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Etnicitet']); // Etnicitet @$Sprog = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Sprog']); // Sprog @$MinVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinVaegt']); // Minimum Vægt @$MaxVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxVaegt']); // Maximum Vægt @$Tatoveringer = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Tatoveringer']); // Tatoveringer @$Kategorier = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kategorier']); // Kategorier // Søgning af ALT starter her. $query = " SELECT users.users_id, any_value(users.users_fornavn), any_value(users.users_mellemnavn), any_value(users.users_efternavn), any_value(users.users_email), any_value(users.users_city), any_value(users.users_zipcode), any_value(users.users_birthday_date), any_value(users.users_address), any_value(users.users_tlf_telefon), any_value(users.users_tlf_mobil), users_info.usersinfo_FK_users_id, any_value(users_info.usersinfo_id), any_value(users_info.usersinfo_profilesearch_viewable), any_value(users_info.usersinfo_hojde_cm), any_value(users_info.usersinfo_vaegt_kg), any_value(users_info.usersinfo_ErfaringKvalifikationer), any_value(users_info.usersinfo_beskaeftigelse), any_value(users_info.usersinfo_FK_usersinfoHairColor_id), any_value(users_info.usersinfo_FK_usersinfoEyeColor_id), any_value(users_info.usersinfo_FK_usersinfoBukseBredde_id), any_value(users_info.usersinfo_FK_usersinfoBukseLaengde_id), any_value(users_info.usersinfo_FK_usersinfoBluseStorrelse_id), any_value(users_info.usersinfo_FK_usersinfoSkoStorrelse_id), any_value(users_info.usersinfo_FK_usersinfoLandsdel_id), any_value(users_info.usersinfo_FK_usersinfoEtnicitet_id), any_value(users_info.usersinfo_FK_usersinfoTatoveringer_id), any_value(users_info.usersinfo_FK_usersinfoKategorier_id), any_value(users_info.usersinfo_FK_usersinfoSprog_id) FROM users INNER JOIN users_info ON users.users_id = users_info.usersinfo_FK_users_id "; // Search patterns - needs editing! from old-original to my version so it fits! include_once("index.search_patterns_setup.php"); // fortsætter herunder $query .= " GROUP BY users_id, usersinfo_FK_users_id"; $result = mysqli_query($dblink, $query) or die(mysqli_error($dblink)); if( mysqli_num_rows($result) > 0 ) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { //echo '<p>her er jeg!</p>'; // indsæt søge resultater her! (DET ING VIIIIRKER!) $output = '<p>'.$query.'</p>'; echo $output; echo '<p>'.$row['users_fornavn'].'</p>'; } } else { $row = '<p>Der var desværre ingen resultater på din søgning. Prøv igen.</p>'; echo $row; $output = '<p>'.$query.'</p>'; echo $output; die(); } } else { include_once("index.no_search_show_cards_profiles.php"); } The small code above is the main file. This code here is where i check for patterns and what has been checked in the form for searching etc... /////////////////////////// ALDER /////////////////////////// if( $MinAlder > 0 ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MinAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date <= '$newtime' "; } if( $MaxAlder > 0 ) { //echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MaxAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date >= '$newtime' "; } /////////////////////////// KØN /////////////////////////// if( !empty($Kon) ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersGender_id = '$Kon' "; } /////////////////////////// LANDSDEL /////////////////////////// if( !empty($Landsdel) ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoLandsdel_id = '$Landsdel' "; } /////////////////////////// ETNICITET /////////////////////////// if( !empty($Etnicitet) ) { echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoEtnicitet_id = '$Etnicitet' "; } /////////////////////////// TATOVERINGER /////////////////////////// if( !empty($Tatoveringer) ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoTatoveringer_id = '$Tatoveringer' "; } /////////////////////////// SPROG /////////////////////////// if( !empty($Sprog) ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoSprog_id = '$Sprog' "; } /////////////////////////// KATEGORIER /////////////////////////// if( !empty($Kategorier) ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoKategorier_id = '$Kategorier' "; } /////////////////////////// VÆGT /////////////////////////// if( $MinVaegt>0 && $MaxVaegt<1 ) { $reg_vaegt_max="999"; } if( $MaxVaegt>0 && $MinVaegt<1 ) { $reg_vaegt_min="1"; } if( $MinVaegt>0 || $MinVaegt>0 ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."userinfo_vaegt_kg BETWEEN $MinVaegt AND $MaxVaegt "; $clause = " OR "; } /////////////////////////// HØJDE /////////////////////////// if( $MinHojde>0 && $MaxHojde<1 ) { $reg_hoejde_max="999"; } if( $MaxHojde>0 && $MinHojde<1 ) { $reg_hoejde_min="1"; } if( $MinHojde>0 || $MinHojde>0 ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! echo clauseCHECK_AND(); //echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."usersinfo_hojde_cm BETWEEN $MinHojde AND $MaxHojde "; $clause = " OR "; } /////////////////////////// KEYWORDS /////////////////////////// //if keyword set, goes here if( !$SearchKeywords=="" ) { echo clauseCHECK_AND(); // Initial clause //echo "<p>".clauseCHECK_AND()."</p>"; // Initial clause // search query $c = " users_id LIKE '%$SearchKeywords%' OR users_fornavn LIKE '%$SearchKeywords%' OR users_mellemnavn LIKE '%$SearchKeywords%' OR users_efternavn LIKE '%$SearchKeywords%' "; $query .= $clause." $c"; } Now, i have a little trouble with the latest version of MySQL installed, i always keep getting the error: Expression #12 of SELECT list is not in GROUP BY clause and contains nonaggregated column (...) which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by So i had to change my main SQL a little, which is why i added "any_value()" to my main sql as a temporary solution, and seems to work, only whenever i get an output, i cannot actually row out any output Oo? Whenever i try to output say "users_fornavn", which is Danish for first name... i get index undefined error... any ideas? I can only assume it it the sql that has the error? Hope you guys can help out a little. PS: Note that the "any_value()" part, was only supposed to be a temporary solution for a customer that want's the website up and running somewhere by next week, so i thought to add the any_value() sql function for now and at a later point be more specific about the code. I just need the rough ways for now so i am able to change that at a later point. Thanks in advance! Really hope you peepz can help me out!
  20. iwato

    Class Variable Declaration

    BACKGROUND: I am now running with PHP 5.5.38, and things are nearly back to normal. My error messages have returned, and things that once worked, now function well again. This said, I wish to make good on the pain and disappointment that I suffered and am requesting your help to do so. REQUEST: Please find below a PHP class that I created in order to gather data from my database. It works fine in my current PHP environment and produces the expected results. It has been upgraded to handle multiple languages and editions of the same letter number. In addition, I have included a list of suspect variables -- namely, variables whose undeclared status may have been a source of difficulty while running in my previous PHP 5.6.33 environment. class Newsletter { public $letter_no; public $letter_lang; public $mysqli_obj; public $letter_ed; public $pc_total; public $podcasts; public function __construct($letter_no, $letter_lang, $mysqli_obj, $letter_ed = 1) { $this->letter_no = $letter_no; $this->letter_lang = $letter_lang; $this->mysqli_obj = $mysqli_obj; $this->letter_ed = $letter_ed; } public function get_letter_data() { $sql = "SELECT letter.*, qa.* FROM sevengates_letter AS letter JOIN sevengates_qa AS qa ON letter.letter_no = qa.letter_no WHERE letter.letter_no = ? AND letter.letter_lang = ? ORDER BY letter.letter_ed DESC"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('is', $this->letter_no, $this->letter_lang); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $letter_results[$name] = $value; } } return $letter_results; } public function get_nextletter_data() { $next_letter_no = $this->letter_no + 1; $sql = "SELECT letter_no, letter_title, letter_abstract FROM sevengates_letter WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $next_letter_no); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } $mysqli_stmt->free_result(); foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $nextletter_results[$name] = $value; } } return $nextletter_results; } public function get_podcasts() { $sql = "SELECT podcast_ref FROM sevengates_podref WHERE letter_no = ?"; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $this->letter_no); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } $prelim_result[] = $c; } $i = 1; foreach ($prelim_result as $arr) { foreach ($arr as $name => $value) { $name = $name . '_' . $i; $podcasts[$name] = $value; } $i++; } $this->pc_total = count($podcasts); return $podcasts; } public function get_podcasts_data($podcasts) { $this->podcasts = $podcasts; $prelim_result = []; $c = []; $row = []; $podcast_results = []; foreach ($podcasts as $name => $value) { $params = []; $mysqli_stmt = $this->mysqli_obj->stmt_init(); $sql = "SELECT item_podtype, podcast_no_item, item_title, item_description, item_guid FROM rss2_podcast_item WHERE podcast_no_item = ?"; $mysqli_stmt->prepare($sql); $mysqli_stmt->bind_param('i', $value); $mysqli_stmt->execute(); $meta = $mysqli_stmt->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array($mysqli_stmt, 'bind_result'), $params); while ($mysqli_stmt->fetch()) { foreach($row as $key => $val) { $c[$key] = $val; } } $prelim_result[] = $c; $mysqli_stmt->free_result(); } foreach ($prelim_result as $arr) { foreach ($arr as $name => $value){ $pc_result[$name] = $value; } $podcast_results[] = $pc_result; } return $podcast_results; } public function get_pc_total() { return $this->pc_total; } } LIST OF SUSPECT VARIABLES $params = []; $prelim_result = []; $c = []; $letter_results = []; $next_letter_results = []; $row = []; $podcast_results = []; DISCUSSION I feel fairly comfortable with handling certain kinds of variables, but very uncomfortable handling others. In fact, I am not at all sure why the above class works, as it took a lot of guess work to make it function. Guess work is inefficient. QUESTION: How does one properly declare class variables that are not related to the arguments of the constructor function? Please provide examples from the list and code provided. Roddy
  21. It's been a long time since that PHP class in college, and the majority of my focus since graduating has been on HTML5 / CSS3 / JavaScript. I'm getting ready to go live with a new website. I have a contact form build with HTML5 and CSS3 with validation done with JavaScript. The only problem is, I'll need a PHP script to send the form via email. Is there a basic, easy to use script that someone could recommend? Also, is it possible that my web host (I'll possibly be going with Go Daddy) will make such a script available? I'm hoping to find something that's essentially plug and play. Thank you
  22. Hello W3S! So i have some problems again, hoping you can help me clear it out. I am currently trying to make a search page where a user can search for profiles with different profiles information such as tattoos, height, etc. And i have some difficulties making it work, hoping you can spot some sort of errors that i cannot. Please note that it's been a while since i've been making a fully working searcher with php and sql, so sorry for the messed up code, if so hehe Okay. So i have 6 files, follows as such: 1. index.php (being the main file) - (LOCATION: ROOT/FILE_HERE.php), 2. PAGE_searchprofiles.php (being where the search coding begins AND output is coming) - (LOCATION: ROOT/include/files/www-files/FILE_HERE.php), 3. functions.pagination.class.php (being my pagination class, used on file PAGE_searchprofiles.php) - (LOCATION: ROOT/FILE_HERE.php), 4. functions.php (my php functions into 1 file) - location is root 5. index.search_patterns_setup.php (being used on file PAGE_searchprofiles.php, being where i use if/else statements to compile a proper sql) - location root 6. index.no_search_show_cards_profiles.php (being used on file PAGE_searchprofiles.php, showing ALL profiles if no search has been done so far.) - location root ------------------------------------------- okay, those are file names and locations. the idea is that when there is a search, the searched profiles should be shown, else, show all files. I got that part working perfectly, but now comes the actual search query where i get a little lost (i think). And please take note that this is a search query from a past coder, doing this for a company and this coder has done some terrible coding... i think... i have a hard time seeing what he has done and not. At some places he has done a quite good job, but the search part, not so much. So, i will share the code below here for ALL files, and after that coding, i will write about the problem at hand again. -------------------------------------- index.php <?php ob_start(); session_start(); define("DEFINED_FILE:DEFINES_1", TRUE); require_once("include/files/www-files/random_uncategorized_useful_files/defines.php"); // Defines require_once("include/files/www-files/random_uncategorized_useful_files/report_methods.php"); // Reportings require_once("database/connection.php"); DB_open_main_connection(); // $dblink ?> <!DOCTYPE html> <html lang="da"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Release 1 - Version 1</title> <!-- Bootstrap V.4.0.0 CSS files --> <link rel="stylesheet" href="include/css/bootstrap.min.css" /> <!-- My Custom CSS Files --> <link rel="stylesheet" href="include/css/global_custom_css_design.css" /> <link rel="stylesheet" href="include/css/5.css" /> <link rel="stylesheet" href="include/css/navigation_menu_5.css" /> <!-- other css files --> <link rel="stylesheet" href="include/css/fontawesome-all.min.css"> <!-- Jquery (necessary for Bootstrap's JavaScript plugins) and Bootstrap V.4.0.0 JS Script files --> <script src="include/js/jquery-3.2.1.js"></script> <script src="include/js/bootstrap.min.js"></script> <script src="include/js/bootstrap.bundle.js"></script> <script src="include/js/5.js"></script> </head> <body> <?php # Require Navigation Menu require_once("include/files/www-files/nav-menu.php"); # Including PAGE_signup1.php include_once("include/files/www-files/PAGE_searchprofiles.php"); ?> <div class="mt-3"></div> <?php # Require Footer require_once("include/files/www-files/footer.php"); // close connection $dblink->close(); // MAIN Connection ?> </body> </html> PAGE_searchprofiles.php <?php require_once("functions.php"); //////////////////////////////////////////////////////////////////////////////////////////////////// // Notes //////////////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------------------ // comma separeret DB output for ALLE checkboxes (Tatovering & Kategori - vi bruger explode!) //------------------------------------------------------------------------------------------------ /* I DB (users_info) laver jeg en "text" for både kategori og tatovering checkboxes da jeg skal bruge string til comma (sådan forstår jeg det!). Jeg indsætter komma sepereret tal, og bruger php funktionen explode til at sepererer tallene. Jeg bruger senere tallene til at "selecte" ud fra ID hos diverse tabeller, senere hen vise diverse som er blevet vist/valgt/osv. */ //////////////////////////////////////////////////////////////////////////////////////////////////// // Lists //////////////////////////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------------------ // FORM - names //------------------------------------------------------------------------------------------------ // my notes: maybe add "multiple" to the select? Style it to be a normale dropdown... look into alternatives! // FORMNAME_SogProfilBar_Keywords (Søg Profil Bar) // FORMNAME_MinAlder (Alder :: Minimum) // FORMNAME_MaxAlder (Alder :: Maximum) // FORMNAME_Landsdel (Landsdel "SelectOption") // FORMNAME_Kon (Køn "SelectOption") // FORMNAME_MinHojde (Højde :: Minimum) // FORMNAME_MaxHojde (Højde :: Maximum) // FORMNAME_Etnicitet (Etnicitet "SelectOption") // FORMNAME_Sprog (Sprog "SelectOption") // FORMNAME_MinVaegt (Vægt :: Minimum) // FORMNAME_MaxVaegt (Vægt :: Maximum) // FORMNAME_Tatoveringer (Tatoveringer "SelectOption") // FORMNAME_Kategorier (Kategorier "SelectOption") // FORMNAME_submit_search (Søg "Submit Button") //------------------------------------------------------------------------------------------------ // Queries - already being used //------------------------------------------------------------------------------------------------ // $query_1 (selecting all data from DB-Table users_info) // $query_2 (Landsdel -> SelectOption) // $query_3 (Køn -> SelectOption) // $query_4 (Etnicitet -> SelectOption) // $query_5 (Sprog -> SelectOption) // $query_6 (Tatoveringer -> SelectOption) // $query_7 (Kategori -> SelectOption) // $query_100 (outputting all cards/profiles to the "profiles" area) //------------------------------------------------------------------------------------------------ // Queries //------------------------------------------------------------------------------------------------ $query_1 = "SELECT * FROM users_info"; $result_1 = mysqli_query($dblink, $query_1) or die ( mysqli_error($dblink) ); $row_1 = mysqli_fetch_array($result_1); ?> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <br /> <h1 class="text-muted text-center">Søg Profiler</h1> </div> </div> </div> <div class="container"> <form method="post" action="index.php"> <div class="row mb-3"> <!-- Søg Profil Bar --> <div class="input-group"> <input type="text" class="form-control" placeholder="Søg Profil" name="FORMNAME_SogProfilBar_Keywords"> <div class="input-group-append"> <button type="submit" class="btn btn-outline-secondary" name="FORMNAME_submit_search">Søg</button> <button type="button" class="btn btn-outline-secondary JQUERY_ACTION_expand_search">Udvid Søgning</button> </div> </div> </div><!-- //.row --> <div class="row"> <div class="container"> <div class="row"> <!-- Min.Alder --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Min.Alder</span> <span class="input-group-text">ÅR</span> </div> <input type="number" class="form-control" placeholder="Min.Alder" min="0" name="FORMNAME_MinAlder"> </div> </div> <!-- Max.Alder --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Max.Alder</span> <span class="input-group-text">ÅR</span> </div> <input type="number" class="form-control" placeholder="Max.Alder" min="0" name="FORMNAME_MaxAlder"> </div> </div> <!-- Landsdel --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_LANDSDEL">Landsdel</label> </div> <select class="custom-select" id="inputGroupSelect_LANDSDEL" name="FORMNAME_Landsdel"> <option selected disabled hidden>Landsdel</option> <?php $query_2 = "SELECT * FROM users_info_landsdel"; $result_2 = mysqli_query($dblink, $query_2) or die ( mysqli_error($dblink) ); while( $row_2 = mysqli_fetch_array($result_2) ) { $selected = ($row_2['usersinfoLandsdel_id'] == $row_1['usersinfo_FK_usersinfoLandsdel_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_2['usersinfoLandsdel_id'].'" '.$selected.'>'.$row_2['usersinfoLandsdel_name'].'</option>'; } ?> </select> </div> </div> <!-- Køn --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_KØN">Køn</label> </div> <select class="custom-select" id="inputGroupSelect_KØN" name="FORMNAME_Kon"> <option selected disabled hidden>Køn</option> <?php $query_3 = "SELECT * FROM users_gender"; $result_3 = mysqli_query($dblink, $query_3) or die ( mysqli_error($dblink) ); while( $row_3 = mysqli_fetch_array($result_3) ) { $selected = ($row_3['usersGender_id'] == $row_1['users_FK_usersGender_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_3['usersGender_id'].'" '.$selected.'>'.$row_3['usersGender_name'].'</option>'; } ?> </select> </div> </div> </div><!-- //.row --> </div><!-- //.container --> </div><!-- //.row --> <div class="row" style="display: none;"> <div class="container mt-3 mb-3"> <div class="row mb-3"> <div class="col-md-3"> &nbsp; </div> <div class="col-md-3"> &nbsp; </div> <div class="col-md-3"> &nbsp; </div> <div class="col-md-3"> <button type="button" class="btn JQUERY_ACTION_minimize_search">Minimer Søgning</button> </div> </div><!-- //.row --> <div class="row mb-3"> <!-- Min.Højde --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Min.Højde</span> <span class="input-group-text">CM</span> </div> <input type="number" class="form-control" placeholder="Min.Højde" min="0" name="FORMNAME_MinHojde"> </div> </div> <!-- Max.Højde --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Max.Højde</span> <span class="input-group-text">CM</span> </div> <input type="number" class="form-control" placeholder="Max.Højde" min="0" name="FORMNAME_MaxHojde"> </div> </div> <!-- Etnicitet --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_ETNICITET">Etnicitet</label> </div> <select class="custom-select" id="inputGroupSelect_ETNICITET" name="FORMNAME_Etnicitet"> <option selected disabled hidden>Etnicitet</option> <?php $query_4 = "SELECT * FROM users_gender"; $result_4 = mysqli_query($dblink, $query_4) or die ( mysqli_error($dblink) ); while( $row_4 = mysqli_fetch_array($result_4) ) { $selected = ($row_4['usersinfoEtnicitet_id'] == $row_1['usersinfo_FK_usersinfoEtnicitet_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_4['usersinfoEtnicitet_id'].'" '.$selected.'>'.$row_4['usersinfoEtnicitet_name'].'</option>'; } ?> </select> </div> </div> <!-- Sprog --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_SPROG">Sprog</label> </div> <select class="custom-select" id="inputGroupSelect_SPROG" name="FORMNAME_Sprog"> <option selected disabled hidden>Sprog</option> <?php $query_5 = "SELECT * FROM users_info_sprog"; $result_5 = mysqli_query($dblink, $query_5) or die ( mysqli_error($dblink) ); while( $row_5 = mysqli_fetch_array($result_5) ) { $selected = ($row_5['usersinfoSprog_id'] == $row_1['usersinfo_FK_usersinfoSprog_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_5['usersinfoSprog_id'].'" '.$selected.'>'.$row_5['usersinfoSprog_name'].'</option>'; } ?> </select> </div> </div> </div><!-- //.row --> <div class="row"> <!-- Min.Vægt --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Min.Vægt</span> <span class="input-group-text">KG</span> </div> <input type="number" class="form-control" placeholder="Min.Vægt" min="0" name="FORMNAME_MinVaegt"> </div> </div> <!-- Max.Vægt --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <span class="input-group-text">Max.Vægt</span> <span class="input-group-text">KG</span> </div> <input type="number" class="form-control" placeholder="Max.Vægt" min="0" name="FORMNAME_MaxVaegt"> </div> </div> <!-- Tatoveringer --> <div class="col-md-3"> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_TATOVERINGER">Tatoveringer</label> </div> <select class="custom-select" id="inputGroupSelect_TATOVERINGER" name="FORMNAME_Tatoveringer"> <option selected disabled hidden>Tatoveringer</option> <?php $query_6 = "SELECT * FROM users_info_tatoveringer"; $result_6 = mysqli_query($dblink, $query_6) or die ( mysqli_error($dblink) ); while( $row_6 = mysqli_fetch_array($result_6) ) { $selected = ($row_6['usersinfoTatoveringer_id'] == $row_1['usersinfo_FK_usersinfoTatoveringer_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_6['usersinfoTatoveringer_id'].'" '.$selected.'>'.$row_6['usersinfoTatoveringer_name'].'</option>'; } ?> </select> </div> </div> <!-- Kategorier --> <div class="col-md-3"> <?php //include_once("include/files/www-files/form_parts/searchprofiles_multiselect/multiselect_kategori.php"); ?> <div class="input-group"> <div class="input-group-prepend"> <label class="input-group-text" for="inputGroupSelect_KATEGORI">Kategorier</label> </div> <select class="custom-select" id="inputGroupSelect_KATEGORI" name="FORMNAME_Kategorier"> <option selected disabled hidden>Kategorier</option> <?php $query_7 = "SELECT * FROM users_info_kategorier"; $result_7 = mysqli_query($dblink, $query_7) or die ( mysqli_error($dblink) ); while( $row_7 = mysqli_fetch_array($result_7) ) { $selected = ($row_7['usersinfoKategorier_id'] == $row_1['usersinfo_FK_usersinfoKategorier_id']) ? 'selected="selected"' : ''; echo '<option value="'.$row_7['usersinfoKategorier_id'].'" '.$selected.'>'.$row_7['usersinfoKategorier_name'].'</option>'; } ?> </select> </div> </div> </div><!-- //.row --> </div><!-- //.container --> </div><!-- //.row (udvidet søgning) --> </form> </div> <div class="mt-3"></div> <div class="container"> <?php if( isset($_POST['FORMNAME_submit_search']) ) { //include_once("functions.pagination.class.php"); // include pagination $qur = ""; @$SearchKeywords = mysqli_real_escape_string($dblink, $_POST['FORMNAME_SogProfilBar_Keywords']); // Search Bar Profil Keywords @$MinAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinAlder']); // Minimum Alder @$MaxAlder = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxAlder']); // Maximum Alder @$Landsdel = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Landsdel']); // Landsdel @$Kon = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kon']); // Køn @$MinHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinHojde']); // Minimum Højde @$MaxHojde = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxHojde']); // Maximum Højde @$Etnicitet = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Etnicitet']); // Etnicitet @$Sprog = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Sprog']); // Sprog @$MinVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MinVaegt']); // Minimum Vægt @$MaxVaegt = mysqli_real_escape_string($dblink, $_POST['FORMNAME_MaxVaegt']); // Maximum Vægt @$Tatoveringer = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Tatoveringer']); // Tatoveringer @$Kategorier = mysqli_real_escape_string($dblink, $_POST['FORMNAME_Kategorier']); // Kategorier // Søgning af ALT starter her. $query = "SET SESSION sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION'"; $result = mysqli_query($dblink, $query) or die(mysqli_error($dblink)); $query = htmlentities(" SELECT DISTINCT users_id, users_fornavn, users_mellemnavn, users_efternavn, users_email, users_city, users_zipcode, users_birthday_date, users_address, users_tlf_telefon, users_tlf_mobil, usersinfo_profilesearch_viewable, usersinfo_hojde_cm, usersinfo_vaegt_kg, usersinfo_ErfaringKvalifikationer, usersinfo_beskaeftigelse, usersinfo_FK_usersinfoHairColor_id, usersinfo_FK_usersinfoEyeColor_id, usersinfo_FK_usersinfoBukseBredde_id, usersinfo_FK_usersinfoBukseLaengde_id, usersinfo_FK_usersinfoBluseStorrelse_id, usersinfo_FK_usersinfoSkoStorrelse_id, usersinfo_FK_usersinfoLandsdel_id, usersinfo_FK_usersinfoEtnicitet_id, usersinfo_FK_usersinfoTatoveringer_id, usersinfo_FK_usersinfoKategorier_id, usersinfo_FK_usersinfoSprog_id, usersGender_id, usersGender_name, usersinfoLandsdel_id, usersinfoLandsdel_name, usersinfoEtnicitet_id, usersinfoEtnicitet_name, usersinfoTatoveringer_id, usersinfoTatoveringer_name, usersinfoSprog_id, usersinfoSprog_name, usersinfoKategorier_id, usersinfoKategorier_name FROM users INNER JOIN users_info ON users.users_id = users_info.usersinfo_FK_users_id INNER JOIN users_gender ON users.users_FK_usersGender_id = users_gender.usersGender_id INNER JOIN users_info_landsdel ON users_info.usersinfo_FK_usersinfoLandsdel_id = users_info_landsdel.usersinfoLandsdel_id INNER JOIN users_info_etnicitet ON users_info.usersinfo_FK_usersinfoEtnicitet_id = users_info_etnicitet.usersinfoEtnicitet_id INNER JOIN users_info_tatoveringer ON users_info.usersinfo_FK_usersinfoTatoveringer_id = users_info_tatoveringer.usersinfoTatoveringer_id INNER JOIN users_info_sprog ON users_info.usersinfo_FK_usersinfoSprog_id = users_info_sprog.usersinfoSprog_id INNER JOIN users_info_kategorier ON users_info.usersinfo_FK_usersinfoKategorier_id = users_info_kategorier.usersinfoKategorier_id "); // Search patterns - needs editing! from old-original to my version so it fits! include_once("index.search_patterns_setup.php"); // fortsætter herunder $query .= " GROUP BY users_id, usersinfo_FK_users_id"; $result = mysqli_query($dblink, $query) or die(mysqli_error($dblink)); // hvis der ikke er EN række i udtrækket, vises en fejlbesked (??? på search eller ???) //$searchCount=mysqli_num_rows($result); // Behøver jeg denne del (???) // OG START PÅ "<?PHP ?\>" - HTML KOMMER HER IFØLGE TIDLIGERE KODE! (tror jeg skipper den del!) if( mysqli_num_rows($result) > 0 ) { while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo '<p>her er jeg!</p>'; // indsæt søge resultater her! } } else { $row = '<p>Der var desværre ingen resultater på din søgning. Prøv igen.</p>'; echo '<h3>'.$row.'</h3>'; die(); } } else { //include_once("functions.pagination.class.php"); // include pagination include_once("index.no_search_show_cards_profiles.php"); } ?> </div> <script> $('.JQUERY_ACTION_expand_search').on('click', function () { $(this).parent().parent().parent().next().next().show(1000); }); $('.JQUERY_ACTION_minimize_search').on('click', function () { $(this).parent().parent().parent().parent().hide(1000); }); </script> functions.pagination.class.php <?php class pagination { /* Properties array @var array @access private */ private $_properties = array(); /* Default configurations @var array @access public */ public $_defaults = array( 'page' => 1, 'perPage' => 10 ); /* Constructor @param array $array Array of results to be paginated @param int $curPage The current page interger that should used @param int $perPage The amount of items that should be show per page @return void @access public */ public function __construct($array, $curPage = null, $perPage = null) { $this->array = $array; $this->curPage = ($curPage == null ? $this->defaults['page'] : $curPage); $this->perPage = ($perPage == null ? $this->defaults['perPage'] : $perPage); } /* Global setter Utilises the properties array @param string $name The name of the property to set @param string $value The value that the property is assigned @return void @access public */ public function __set($name, $value) { $this->_properties[$name] = $value; } /* Global getter Takes a param from the properties array if it exists @param string $name The name of the property to get @return mixed Either the property from the internal properties array or false if isn't set @access public */ public function __get($name) { if (array_key_exists($name, $this->_properties)) { return $this->_properties[$name]; } return false; } /* Set the show first and last configuration This will enable the "<< first" and "last >>" style links @param boolean $showFirstAndLast True to show, false to hide. @return void @access public */ public function setShowFirstAndLast($showFirstAndLast) { $this->_showFirstAndLast = $showFirstAndLast; } /* Set the main seperator character By default this will implode an empty string @param string $mainSeperator The seperator between the page numbers @return void @access public */ public function setMainSeperator($mainSeperator) { $this->mainSeperator = $mainSeperator; } /* Get the result portion from the provided array @return array Reduced array with correct calculated offset @access public */ public function getResults() { // Assign the page variable if (empty($this->curPage) !== false) { $this->page = $this->curPage; // using the get method } else { $this->page = 1; // if we don't have a page number then assume we are on the first page } // Take the length of the array $this->length = count($this->array); // Get the number of pages $this->pages = ceil($this->length / $this->perPage); // Calculate the starting point $this->start = ceil(($this->page - 1) * $this->perPage); // return the portion of results return array_slice($this->array, $this->start, $this->perPage); } /* Get the html links for the generated page offset @param array $params A list of parameters (probably get/post) to pass around with each request @return mixed Return description (if any)... @access public */ public function getLinks($params = array()) { // Initiate the links array $plinks = array(); $links = array(); $slinks = array(); // Concatenate the get variables to add to the page numbering string $queryUrl = ''; if (!empty($params) === true ) { unset($params['page']); $queryUrl = '&amp;'.http_build_query($params); } // If we have more then one pages if (($this->pages) > 1) { // Assign the 'previous page' link into the array if we are not on the first page if ($this->page != 1) { if ($this->_showFirstAndLast) { $plinks[] = ' <a href="?page=1'.$queryUrl.'">&laquo;&laquo; First </a> '; } $plinks[] = ' <a href="?page='.($this->page - 1).$queryUrl.'">&laquo; Prev</a> '; } // Assign all the page numbers & links to the array for ($j = 1; $j < ($this->pages + 1); $j++) { if ($this->page == $j) { $links[] = ' <a class="selected">'.$j.'</a> '; // If we are on the same page as the current item } else { $links[] = ' <a href="?page='.$j.$queryUrl.'">'.$j.'</a> '; // add the link to the array } } // Assign the 'next page' if we are not on the last page if ($this->page < $this->pages) { $slinks[] = ' <a href="?page='.($this->page + 1).$queryUrl.'"> Next &raquo; </a> '; if ($this->_showFirstAndLast) { $slinks[] = ' <a href="?page='.($this->pages).$queryUrl.'"> Last &raquo;&raquo; </a> '; } } // Push the array into a string using any some glue return implode(' ', $plinks).implode($this->mainSeperator, $links).implode(' ', $slinks); } return; } } functions.php <?php // clause CHECK AND function // function clauseCHECK_AND () { global $clause; if( isset($clause) ) { $clause = " AND "; //echo "CLAUSE ER WHERE:"; } else { $clause = " WHERE "; } } // clause CHECK OR function // function clauseCHECK_OR () { global $clause; if( isset($clause) ) { $clause = " OR "; //echo "CLAUSE ER WHERE:"; } else { $clause = " WHERE "; } } ?> index.no_search_show_cards_profiles.php <div class="container"> <div class="card-columns"> <?php $query_100 = "SELECT * FROM users ORDER BY users_id DESC"; $result_100 = mysqli_query($dblink, $query_100) or die(mysqli_error($dblink)); if( mysqli_num_rows($result_100) > 0 ) { if( mysqli_num_rows($result_100) > 0 ) { while( $row_100 = mysqli_fetch_array($result_100) ) { $user_id = $row_100['users_id']; $user_fornavn = $row_100['users_fornavn']; $dateOfBirth = $row_100['users_birthday_date']; // output: Y-m-d (Year-Month-Day) $today = date("Y-m-d"); // current date today $diff = date_diff(date_create($dateOfBirth), date_create($today)); // difference between the two dates ?> <div class="card"> <a href="#" title="Profil"> <img class="card-img-top img-responsive img-rounded" src="https://dummyimage.com/250x330/000/fff.jpg" alt="Billede"> </a> <div class="card-body"> <h5 class="card-title"><b><?php echo $user_fornavn.',&nbsp;'.$diff->format('%y'); ?></b></h5> <p class="card-text">#<?php echo $user_id; ?></p> </div><!-- //.card-body --> </div><!-- //.card --> <?php } } } else { echo 'Intet at vise lige nu.'; } ?> </div> </div> index.search_patterns_setup.php <?php /////////////////////////// ALDER /////////////////////////// // ORIGINAL /* if( $minAlder > 0 ) { $time = new DateTime('now'); $newtime = $time->modify('-'.$minAlder.' year')->format('Y-m-d'); //echo $newtime; echo clauseCHECK(); $query .= $clause." user_dob <= '$newtime' "; //$clause .= " OR ";//Change to OR after 1st WHERE } if( $maxAlder > 0 ) { echo clauseCHECK(); $time = new DateTime('now'); $newtime = $time->modify('-'.$maxAlder.' year')->format('Y-m-d'); //echo $newtime; $query .= $clause." user_dob >= '$newtime' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( $MinAlder > 0 ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MinAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date <= '$newtime' "; } if( $MaxAlder > 0 ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; // dob = Date Of Birth $time = new DateTime('now'); $newtime = $time->modify('-'.$MaxAlder.' year')->format('Y-m-d'); $query .= $clause." users_birthday_date >= '$newtime' "; } /////////////////////////// KØN /////////////////////////// // ORIGINAL /* if( !empty($reg_koen) ) { echo clauseCHECK(); $query .= $clause." user_koen = '$reg_koen' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( !empty($Kon) ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersGender_id = '$Kon' "; } /////////////////////////// LANDSDEL /////////////////////////// // ORIGINAL /* if( !empty($reg_Landsdel) ) { echo clauseCHECK(); $query .= $clause." user_landsdel = '$reg_Landsdel' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( !empty($Landsdel) ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoLandsdel_id = '$Landsdel' "; } /////////////////////////// ETNICITET /////////////////////////// // ORIGINAL /* if( !empty($reg_etnic) ) { echo clauseCHECK(); $query .= $clause." user_etnicitet = '$reg_etnic' "; //$clause .= " OR ";//Change to OR after 1st WHERE } */ // MY VERSION if( !empty($Etnicitet) ) { //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoEtnicitet_id = '$Etnicitet' "; } /////////////////////////// TATOVERINGER /////////////////////////// // ORIGINAL /* if( !empty($_POST['check_listTat']) ) { // Loop to store and display values of individual checked checkbox. foreach($_POST['check_listTat'] as $c) { if( !empty($c) ) { echo clauseCHECKor(); $qur = "userPers_fk_tat_id"; $query .= $clause."".$qur." LIKE '%{$c}%'"; //$clause = " OR ";//Change to OR after 1st WHERE } } } */ // MY VERSION if( !empty($Tatoveringer) ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoTatoveringer_id = '$Tatoveringer' "; } /////////////////////////// SPROG /////////////////////////// // ORIGINAL /* if( !empty($_POST['check_listSprog']) ) { // Loop to store and display values of individual checked checkbox. foreach($_POST['check_listSprog'] as $c) { if( !empty($c) ) { echo clauseCHECKor(); $qur = "userPers_fk_sprog_id"; $query .= $clause."".$qur." LIKE '%{$c}%'"; $clause = " OR "; //Change to OR after 1st WHERE } } //echo $query;//Remove after testing } */ // MY VERSION if( !empty($Sprog) ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoSprog_id = '$Sprog' "; } /////////////////////////// KATEGORIER /////////////////////////// // ORIGINAL /* if( !empty($_POST['check_listKat']) ) { // Loop to store and display values of individual checked checkbox. // Loop to store and display values of individual checked checkbox. foreach($_POST['check_listKat'] as $c) { if( !empty($c) ) { echo clauseCHECKor(); $qur = "userPers_fk_kat_id"; $query .= $clause."".$qur." LIKE '%{$c}%'"; $clause = " OR ";//Change to OR after 1st WHERE } } } */ // MY VERSION if( !empty($Kategorier) ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause." usersinfoKategorier_id = '$Kategorier' "; } /////////////////////////// VÆGT /////////////////////////// // ORIGINAL /* if( $reg_vaegt_min>0 && $reg_vaegt_max<1 ) { $reg_vaegt_max="999"; } if( $reg_vaegt_max>0 && $reg_vaegt_min<1 ) { $reg_vaegt_min="1"; } if( $reg_vaegt_min>0 || $reg_vaegt_min>0 ) { echo clauseCHECK(); //echo "<br><hr><br>HER er vægt.<br><br>"; $query .= $clause."user_vaegt BETWEEN $reg_vaegt_min AND $reg_vaegt_max "; $clause = " OR "; } */ // MY VERSION if( $MinVaegt>0 && $MaxVaegt<1 ) { $reg_vaegt_max="999"; } if( $MaxVaegt>0 && $MinVaegt<1 ) { $reg_vaegt_min="1"; } if( $MinVaegt>0 || $MinVaegt>0 ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."userinfo_vaegt_kg BETWEEN $MinVaegt AND $MaxVaegt "; $clause = " OR "; } /////////////////////////// HØJDE /////////////////////////// // ORIGINAL /* if( $reg_hoejde_min>0 && $reg_hoejde_max<1 ) { $reg_hoejde_max="999"; } if( $reg_hoejde_max>0 && $reg_hoejde_min<1 ) { $reg_hoejde_min="1"; } if( $reg_hoejde_min>0 || $reg_hoejde_min>0 ) { echo clauseCHECK(); //echo "<br><hr><br>HER er vægt.<br><br>"; $query .= $clause."user_hoejde BETWEEN $reg_hoejde_min AND $reg_hoejde_max "; $clause = " OR "; } */ // MY VERSION if( $MinHojde>0 && $MaxHojde<1 ) { $reg_hoejde_max="999"; } if( $MaxHojde>0 && $MinHojde<1 ) { $reg_hoejde_min="1"; } if( $MinHojde>0 || $MinHojde>0 ) { // når jeg skifter til checkboxes, bruger jeg clauseCHECK_OR()! Som den bruges i de originale! Tjek for eksempler! //echo clauseCHECK_AND(); echo "<p>".clauseCHECK_AND()."</p>"; $query .= $clause."usersinfo_hojde_cm BETWEEN $MinHojde AND $MaxHojde "; $clause = " OR "; } /////////////////////////// KEYWORDS /////////////////////////// // ORIGINAL /* //if keyword set, goes here if( !$keyword=="" ) { echo clauseCHECK();//Initial clause $c=" user_unikID LIKE '%$keyword%' OR user_fornavn LIKE '%$keyword%' OR user_efternavn LIKE '%$keyword%' OR user_faerdigheder LIKE '%$keyword%' OR user_etnicitet LIKE '%$keyword%' OR user_haarfarve LIKE '%$keyword%' OR user_haartype LIKE '%$keyword%' OR user_ojenfarve LIKE '%$keyword%' "; $query .= $clause." $c"; } */ // MY VERSION //if keyword set, goes here if( !$SearchKeywords=="" ) { //echo clauseCHECK_AND(); // Initial clause echo "<p>".clauseCHECK_AND()."</p>"; // Initial clause // unikID = old wwww-files :: ROOT/call/reg_sessioncall.php :: line ~290+ (cirka) // search query /* $c = " user_unikID LIKE '%$SearchKeywords%' OR users_fornavn LIKE '%$SearchKeywords%' OR users_mellemnavn LIKE '%$SearchKeywords%' OR users_efternavn LIKE '%$SearchKeywords%' OR users_faerdigheder LIKE '%$SearchKeywords%' OR user_etnicitet LIKE '%$SearchKeywords%' OR user_haarfarve LIKE '%$SearchKeywords%' OR user_haartype LIKE '%$SearchKeywords%' OR user_ojenfarve LIKE '%$SearchKeywords%' "; */ $c = " user_unikID LIKE '%$SearchKeywords%' OR users_fornavn LIKE '%$SearchKeywords%' OR users_mellemnavn LIKE '%$SearchKeywords%' OR users_efternavn LIKE '%$SearchKeywords%' "; $query .= $clause." $c"; } ?> ----------------------------------------------------------------- Okay, as you might have guessed, the code is a little long. (yay). Okay, so i have "tried" to clean up the past coding the best i could, BUT, here is where i get lost a bit. In the main query on PAGE_searchprofiles.php - am i supposed to make a lot of inner joins? I did that one myself, but wonna make sure BECAUSE! I have a LOT of tables and rows in the DB. I have a main table, users, where basic info is like firstname, etc. Then i have another called users_info, having a lot of integers with 1ns and zeros... those numbers are supposed to go to another table, for each table with Foreign Keys (FK), containing names, etc of forms and so on. I thought it would be better this way for the select at the time, and it was, but also worse for the search query because i have no idea if i am doing that part correct. Also with the file (index.search_patterns_setup.php) - not sure if i do the if/else's correct, since i just reused the old coders parameters and just changed the variables and queries to my database and variable names so they would look perfectly, and they do, only not sure if it's working or not :/ Mostly because whenever i make a search, nothing comes out, no errors either, just no rows. Not sure if i pinpoint the whole thing at different ways with id's etc with inner joins at the main query and the parameters if/else's statements. This is my current DB (query a little bit, but if you can check it out, go for it, just remember, it is in Danish some of it and some in English... combined the 2 languages for some text hehe): -- phpMyAdmin SQL Dump -- version 4.7.0 -- https://www.phpmyadmin.net/ -- -- Host: localhost -- Generation Time: Mar 10, 2018 at 10:35 AM -- Server version: 5.7.18 -- PHP Version: 7.1.5 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `u1d4zzx` -- -- -------------------------------------------------------- -- -- Table structure for table `carousel1` -- CREATE TABLE `carousel1` ( `carousel1_id` int(11) NOT NULL, `carousel1_img_url` text NOT NULL, `carousel1_title` text NOT NULL, `carousel1_description` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `carousel1` -- INSERT INTO `carousel1` (`carousel1_id`, `carousel1_img_url`, `carousel1_title`, `carousel1_description`) VALUES (1, '1.PNG', 'No Title 1', 'No Description 1'), (2, '2.jpg', 'No Title 2', 'No Description 2'), (3, '3.jpg', 'No Title 3', 'No Description 3'), (4, '4.jpeg', 'No Title 4', 'No Description 4'); -- -------------------------------------------------------- -- -- Table structure for table `page_work1_videos` -- CREATE TABLE `page_work1_videos` ( `pw1videos_id` int(11) NOT NULL, `pw1videos_link` text NOT NULL, `pw1videos_director` text NOT NULL, `pw1videos_title` text NOT NULL, `pw1videos_text` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `page_work1_videos` -- INSERT INTO `page_work1_videos` (`pw1videos_id`, `pw1videos_link`, `pw1videos_director`, `pw1videos_title`, `pw1videos_text`) VALUES (6, 'DxiOVmuZyw4', 'Simon Bonde', 'Tuborg Classic', 'All Cast'), (7, 'BDhC7DU0yYE', ' ', 'Hi-Fi Klubben', 'Extras'), (8, 'nN1GLigSw40', 'Jannik Vestmar', 'Krifa', 'All Cast'), (9, 'wBC1WWO9AUc', 'Stevan Treshow', 'Oddset', 'All Cast'), (10, 'FH5cw-n00T8', 'Stevan Treshow', 'Oddset', 'All Cast'), (11, 'L7D1G8vgkEQ', 'Stevan Treshow', 'Oddset', 'All Cast'), (12, '_kASjW_aPbQ', 'Nadia Marquard', 'Emelie Sandé Wonder', 'Cast & Extras'), (14, '0rbA2qBDn8A', ' ', 'Ikano Bank', 'Cast '), (15, 'NYndyqp1gDU', ' ', 'Just Eat', 'All Cast'), (16, 't9diF_GKImA', ' ', 'Just Eat', 'All Cast'), (17, 'zvK8WL43kdY', 'Jonas Elmer', 'Betsafe', 'Cast '), (18, '0bPWGoTRFc0', 'Michael Langhoff', 'Øresundsbroen', 'Extras'), (19, 'MBcU7VCh_MM', 'Michael Langhoff', 'Øresundsbroen', 'Extras'), (20, '_m_KUK6QFS0', 'Michael Langhoff', 'Øresundsbroen', 'Extras'), (21, 'p7QrsVAEwIU', 'Michael Langhoff', 'Øresundsbroen', 'Extras'), (23, 'hmdlCmLrD8A', 'Simon Bonde & Michael Spooner', 'Ladbrokes', 'Cast & Extras'), (29, 'TjHSXd0CcNI', 'Fredrik Callinggard', 'Ofir', 'All Cast'), (30, 'CfAyPqhbeCM', 'Mats Stenberg', 'Casino.dk', 'Ekstra'), (31, 'Aml0d-e6czg', 'Michael Langhoff', 'DayDose', 'Extras'), (32, '5AdMpkKrlDE', '', 'Unibet ', 'Extras'), (33, 'jY-PZ4tMwXU', '', 'Unibet', 'Extras'), (38, '7Cd3UbueGzM', 'Fredrik Callinggard', 'Ofir', 'All Cast'), (42, 'R3JqzsNuer8', 'Gaute Hesthagen ', 'Telenor', 'All Cast'), (46, 'mmHpWlTZEk4', 'Gaute Hesthagen ', 'Telenor', 'All Cast'), (47, 'W3p0yzLc_js', 'Gaute Hesthagen ', 'Telenor', 'All Cast'), (49, '8IIGUBV-jqo', ' ', 'Mobilepay', 'All Cast'), (50, 'MQ_uMGxRvH8', '', 'Bygma', 'Extras'); -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `users_id` int(11) NOT NULL, `users_ActiveState` int(11) NOT NULL DEFAULT '0', `users_fornavn` varchar(255) NOT NULL, `users_mellemnavn` varchar(255) NOT NULL, `users_efternavn` varchar(255) NOT NULL, `users_email` text NOT NULL, `users_password` text NOT NULL, `users_FK_usersGender_id` int(11) NOT NULL DEFAULT '0', `users_city` varchar(255) NOT NULL, `users_zipcode` int(11) NOT NULL, `users_birthday_date` date DEFAULT NULL, `users_address` text NOT NULL, `users_tlf_telefon` int(11) NOT NULL DEFAULT '0', `users_tlf_mobil` int(11) NOT NULL DEFAULT '0', `users_FK_usersSubscription_id` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users` -- INSERT INTO `users` (`users_id`, `users_ActiveState`, `users_fornavn`, `users_mellemnavn`, `users_efternavn`, `users_email`, `users_password`, `users_FK_usersGender_id`, `users_city`, `users_zipcode`, `users_birthday_date`, `users_address`, `users_tlf_telefon`, `users_tlf_mobil`, `users_FK_usersSubscription_id`) VALUES (2, 1, 'd', 'd', 'd', 'd@yahoo.co.uk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'FREDERIKSBERG C', 1851, '1992-11-08', 'Nyvej 16, 2TV', 44444444, 44444444, 3), (3, 0, 'dwjioj', 'odj', 'woidjo', 'derp@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'd C', 1851, '1992-11-08', 'diwjdo, 2TV', 44444444, 44444444, 2), (4, 0, 'Danie', ' ', 'Pedersen', 'd@yahoo.com', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'd C', 1851, '1992-11-08', ' ', 44444444, 44444444, 1), (5, 0, 'Uglen', ' ', 'Elsker', 'demo1@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 6666, '1992-11-08', ' ', 44444444, 44444444, 1), (6, 0, 'Ugleerne', ' ', 'Elskerne', 'demo2@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 6666, '1992-11-08', ' ', 44444444, 44444444, 1), (7, 0, 'derpy', ' ', 'derp', 'demo3@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 2000, '1992-11-08', ' ', 44444444, 51444379, 3), (8, 0, 'wdwe', '', 'dwad', 'demo4@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 5151, '2018-12-31', '', 51444379, 44444444, 1), (9, 0, 'wdwe', '', 'dwad', 'demo5@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 1, 'd C', 5151, '2018-12-31', '', 44444444, 51444379, 1), (10, 0, 'Karsten', '', 'Larsen', 'demo7@yahoo.dk', '4c65f054573c27e35eefcdd5d6b31091516827fa', 2, 'd C', 1851, '1992-11-08', '', 51444379, 44444444, 1); -- -------------------------------------------------------- -- -- Table structure for table `users_files` -- CREATE TABLE `users_files` ( `usersFiles_id` int(11) NOT NULL, `usersFiles_FK_users_id` int(11) NOT NULL DEFAULT '0', `usersFiles_avatar_1` text NOT NULL, `usersFiles_image_1` text NOT NULL, `usersFiles_image_2` text NOT NULL, `usersFiles_image_3` text NOT NULL, `usersFiles_image_4` text NOT NULL, `usersFiles_image_5` text NOT NULL, `usersFiles_image_6` text NOT NULL, `usersFiles_image_7` text NOT NULL, `usersFiles_image_8` text NOT NULL, `usersFiles_image_9` text NOT NULL, `usersFiles_image_10` text NOT NULL, `usersFiles_video_1` text NOT NULL, `usersFiles_video_2` text NOT NULL, `usersFiles_video_3` text NOT NULL, `usersFiles_video_4` text NOT NULL, `usersFiles_video_5` text NOT NULL, `usersFiles_video_6` text NOT NULL, `usersFiles_video_7` text NOT NULL, `usersFiles_video_8` text NOT NULL, `usersFiles_video_9` text NOT NULL, `usersFiles_video_10` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_files` -- INSERT INTO `users_files` (`usersFiles_id`, `usersFiles_FK_users_id`, `usersFiles_avatar_1`, `usersFiles_image_1`, `usersFiles_image_2`, `usersFiles_image_3`, `usersFiles_image_4`, `usersFiles_image_5`, `usersFiles_image_6`, `usersFiles_image_7`, `usersFiles_image_8`, `usersFiles_image_9`, `usersFiles_image_10`, `usersFiles_video_1`, `usersFiles_video_2`, `usersFiles_video_3`, `usersFiles_video_4`, `usersFiles_video_5`, `usersFiles_video_6`, `usersFiles_video_7`, `usersFiles_video_8`, `usersFiles_video_9`, `usersFiles_video_10`) VALUES (1, 2, '9e711fd22a826bf711a2f748692cf781.jpg', '', '', '', '', '', '', '', '', '', '16b72540e572da3f3ab5753e6034ab2d--rubber-catsuit-fetish-fashion.jpg', '', '', '', '', '', '', '', 'C3322_B_1.jpg', '', ''), (2, 10, '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', ''); -- -------------------------------------------------------- -- -- Table structure for table `users_gender` -- CREATE TABLE `users_gender` ( `usersGender_id` int(11) NOT NULL, `usersGender_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_gender` -- INSERT INTO `users_gender` (`usersGender_id`, `usersGender_name`) VALUES (1, 'Andet'), (2, 'Mand'), (3, 'Kvinde'); -- -------------------------------------------------------- -- -- Table structure for table `users_info` -- CREATE TABLE `users_info` ( `usersinfo_id` int(11) NOT NULL, `usersinfo_FK_users_id` int(11) NOT NULL DEFAULT '0', `usersinfo_hojde_cm` int(11) NOT NULL DEFAULT '0', `usersinfo_vaegt_kg` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoHairColor_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoEyeColor_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoBukseBredde_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoBukseLaengde_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoBluseStorrelse_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoSkoStorrelse_id` int(11) NOT NULL DEFAULT '0', `usersinfo_ErfaringKvalifikationer` text NOT NULL, `usersinfo_beskaeftigelse` text NOT NULL, `usersinfo_profilesearch_viewable` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoTatoveringer_id` varchar(255) NOT NULL, `usersinfo_FK_usersinfoKategorier_id` varchar(255) NOT NULL, `usersinfo_FK_usersinfoSprog_id` varchar(255) NOT NULL, `usersinfo_FK_usersinfoLandsdel_id` int(11) NOT NULL DEFAULT '0', `usersinfo_FK_usersinfoEtnicitet_id` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info` -- INSERT INTO `users_info` (`usersinfo_id`, `usersinfo_FK_users_id`, `usersinfo_hojde_cm`, `usersinfo_vaegt_kg`, `usersinfo_FK_usersinfoHairColor_id`, `usersinfo_FK_usersinfoEyeColor_id`, `usersinfo_FK_usersinfoBukseBredde_id`, `usersinfo_FK_usersinfoBukseLaengde_id`, `usersinfo_FK_usersinfoBluseStorrelse_id`, `usersinfo_FK_usersinfoSkoStorrelse_id`, `usersinfo_ErfaringKvalifikationer`, `usersinfo_beskaeftigelse`, `usersinfo_profilesearch_viewable`, `usersinfo_FK_usersinfoTatoveringer_id`, `usersinfo_FK_usersinfoKategorier_id`, `usersinfo_FK_usersinfoSprog_id`, `usersinfo_FK_usersinfoLandsdel_id`, `usersinfo_FK_usersinfoEtnicitet_id`) VALUES (1, 2, 176, 130, 4, 1, 14, 21, 6, 29, ' Info tekst mangler. ', ' Info tekst mangler. ', 0, '', '', '', 0, 0); -- -------------------------------------------------------- -- -- Table structure for table `users_info_bluse_storrelse` -- CREATE TABLE `users_info_bluse_storrelse` ( `usersinfoBluseStorrelse_id` int(11) NOT NULL, `usersinfoBluseStorrelse_storrelse` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_bluse_storrelse` -- INSERT INTO `users_info_bluse_storrelse` (`usersinfoBluseStorrelse_id`, `usersinfoBluseStorrelse_storrelse`) VALUES (1, 'X-Small'), (2, 'Small'), (3, 'Medium'), (4, 'Large'), (5, 'X-Large'), (6, 'XX-Large'), (7, 'XXX-Large'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_bukse_bredde` -- CREATE TABLE `users_info_bukse_bredde` ( `usersinfoBukseBredde_id` int(11) NOT NULL, `usersinfoBukseBredde_bredde` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_bukse_bredde` -- INSERT INTO `users_info_bukse_bredde` (`usersinfoBukseBredde_id`, `usersinfoBukseBredde_bredde`) VALUES (1, 24), (2, 25), (3, 26), (4, 27), (5, 28), (6, 29), (7, 30), (8, 31), (9, 32), (10, 33), (11, 34), (12, 35), (13, 36), (14, 37), (15, 38), (16, 39), (17, 40), (18, 41), (19, 42), (20, 43), (21, 44), (22, 45); -- -------------------------------------------------------- -- -- Table structure for table `users_info_bukse_laengde` -- CREATE TABLE `users_info_bukse_laengde` ( `usersinfoBukseLaengde_id` int(11) NOT NULL, `usersinfoBukseLaengde_laengde` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_bukse_laengde` -- INSERT INTO `users_info_bukse_laengde` (`usersinfoBukseLaengde_id`, `usersinfoBukseLaengde_laengde`) VALUES (1, 24), (2, 25), (3, 26), (4, 27), (5, 28), (6, 29), (7, 30), (8, 31), (9, 32), (10, 33), (11, 34), (12, 35), (13, 36), (14, 37), (15, 38), (16, 39), (17, 40), (18, 41), (19, 42), (20, 43), (21, 44), (22, 45), (23, 46), (24, 47), (25, 48); -- -------------------------------------------------------- -- -- Table structure for table `users_info_etnicitet` -- CREATE TABLE `users_info_etnicitet` ( `usersinfoEtnicitet_id` int(11) NOT NULL, `usersinfoEtnicitet_name` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `users_info_eye_color` -- CREATE TABLE `users_info_eye_color` ( `usersinfoEyeColor_id` int(11) NOT NULL, `usersinfoEyeColor_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_eye_color` -- INSERT INTO `users_info_eye_color` (`usersinfoEyeColor_id`, `usersinfoEyeColor_name`) VALUES (1, 'Blå'), (2, 'Grønne'), (3, 'Brune'), (4, 'Grå'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_hair_color` -- CREATE TABLE `users_info_hair_color` ( `usersinfoHairColor_id` int(11) NOT NULL, `usersinfoHairColor_color` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_hair_color` -- INSERT INTO `users_info_hair_color` (`usersinfoHairColor_id`, `usersinfoHairColor_color`) VALUES (1, 'Hvidt'), (2, 'Platinblond'), (3, 'Lysblond'), (4, 'Mellemblond'), (5, 'Mørkeblond'), (6, 'Rødblond'), (7, 'Rød'), (8, 'Lysebrunt'), (9, 'Brunt'), (10, 'Mørkebrunt'), (11, 'Sort'), (12, 'Gråt'), (13, 'Grå stænk'), (14, 'Anden'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_kategorier` -- CREATE TABLE `users_info_kategorier` ( `usersinfoKategorier_id` int(11) NOT NULL, `usersinfoKategorier_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_kategorier` -- INSERT INTO `users_info_kategorier` (`usersinfoKategorier_id`, `usersinfoKategorier_name`) VALUES (1, 'Uddannet skuespiller'), (2, 'Autodidakt skuespiller'), (3, 'Ingen erfaring (indenfor film, reklamer, TV)'), (4, 'Statist'), (5, 'Sanger'), (6, 'Danser'), (7, 'Tvilling'), (8, 'Mor til børn'), (9, 'Far til børn'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_landsdel` -- CREATE TABLE `users_info_landsdel` ( `usersinfoLandsdel_id` int(11) NOT NULL, `usersinfoLandsdel_name` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_landsdel` -- INSERT INTO `users_info_landsdel` (`usersinfoLandsdel_id`, `usersinfoLandsdel_name`) VALUES (1, 'Sjælland'), (2, 'Jylland'), (3, 'Odense'), (4, 'Bornholm'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_sko_storrelse` -- CREATE TABLE `users_info_sko_storrelse` ( `usersinfoSkoStorrelse_id` int(11) NOT NULL, `usersinfoSkoStorrelse_storrelse` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_sko_storrelse` -- INSERT INTO `users_info_sko_storrelse` (`usersinfoSkoStorrelse_id`, `usersinfoSkoStorrelse_storrelse`) VALUES (1, 17), (2, 18), (3, 19), (4, 20), (5, 21), (6, 22), (7, 23), (8, 24), (9, 25), (10, 26), (11, 27), (12, 28), (13, 29), (14, 30), (15, 31), (16, 32), (17, 33), (18, 34), (19, 35), (20, 36), (21, 37), (22, 38), (23, 39), (24, 40), (25, 41), (26, 42), (27, 43), (28, 44), (29, 45), (30, 46), (31, 47), (32, 48), (33, 49), (34, 50); -- -------------------------------------------------------- -- -- Table structure for table `users_info_sprog` -- CREATE TABLE `users_info_sprog` ( `usersinfoSprog_id` int(11) NOT NULL, `usersinfoSprog_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_info_sprog` -- INSERT INTO `users_info_sprog` (`usersinfoSprog_id`, `usersinfoSprog_name`) VALUES (1, 'Dansk'), (2, 'Engelsk (US)'), (3, 'Engelsk (UK)'), (4, 'Norsk'), (5, 'Svensk'), (6, 'Tysk'), (7, 'Fransk'); -- -------------------------------------------------------- -- -- Table structure for table `users_info_tatoveringer` -- CREATE TABLE `users_info_tatoveringer` ( `usersinfoTatoveringer_id` int(11) NOT NULL, `usersinfoTatoveringer_name` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- -- Table structure for table `users_subscription` -- CREATE TABLE `users_subscription` ( `usersSubscription_id` int(11) NOT NULL, `usersSubscription_name` varchar(255) NOT NULL, `usersSubscription_months` int(11) NOT NULL DEFAULT '0', `usersSubscription_price` int(11) NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -- Dumping data for table `users_subscription` -- INSERT INTO `users_subscription` (`usersSubscription_id`, `usersSubscription_name`, `usersSubscription_months`, `usersSubscription_price`) VALUES (1, '1 MDR 35,-', 1, 35), (2, '6 MDR 198,-', 6, 198), (3, '12 MDR 349,-', 12, 349); -- -- Indexes for dumped tables -- -- -- Indexes for table `carousel1` -- ALTER TABLE `carousel1` ADD PRIMARY KEY (`carousel1_id`); -- -- Indexes for table `page_work1_videos` -- ALTER TABLE `page_work1_videos` ADD PRIMARY KEY (`pw1videos_id`); -- -- Indexes for table `users` -- ALTER TABLE `users` ADD PRIMARY KEY (`users_id`); -- -- Indexes for table `users_files` -- ALTER TABLE `users_files` ADD PRIMARY KEY (`usersFiles_id`); -- -- Indexes for table `users_gender` -- ALTER TABLE `users_gender` ADD PRIMARY KEY (`usersGender_id`); -- -- Indexes for table `users_info` -- ALTER TABLE `users_info` ADD PRIMARY KEY (`usersinfo_id`); -- -- Indexes for table `users_info_bluse_storrelse` -- ALTER TABLE `users_info_bluse_storrelse` ADD PRIMARY KEY (`usersinfoBluseStorrelse_id`); -- -- Indexes for table `users_info_bukse_bredde` -- ALTER TABLE `users_info_bukse_bredde` ADD PRIMARY KEY (`usersinfoBukseBredde_id`); -- -- Indexes for table `users_info_bukse_laengde` -- ALTER TABLE `users_info_bukse_laengde` ADD PRIMARY KEY (`usersinfoBukseLaengde_id`); -- -- Indexes for table `users_info_etnicitet` -- ALTER TABLE `users_info_etnicitet` ADD PRIMARY KEY (`usersinfoEtnicitet_id`); -- -- Indexes for table `users_info_eye_color` -- ALTER TABLE `users_info_eye_color` ADD PRIMARY KEY (`usersinfoEyeColor_id`); -- -- Indexes for table `users_info_hair_color` -- ALTER TABLE `users_info_hair_color` ADD PRIMARY KEY (`usersinfoHairColor_id`); -- -- Indexes for table `users_info_kategorier` -- ALTER TABLE `users_info_kategorier` ADD PRIMARY KEY (`usersinfoKategorier_id`); -- -- Indexes for table `users_info_landsdel` -- ALTER TABLE `users_info_landsdel` ADD PRIMARY KEY (`usersinfoLandsdel_id`); -- -- Indexes for table `users_info_sko_storrelse` -- ALTER TABLE `users_info_sko_storrelse` ADD PRIMARY KEY (`usersinfoSkoStorrelse_id`); -- -- Indexes for table `users_info_sprog` -- ALTER TABLE `users_info_sprog` ADD PRIMARY KEY (`usersinfoSprog_id`); -- -- Indexes for table `users_info_tatoveringer` -- ALTER TABLE `users_info_tatoveringer` ADD PRIMARY KEY (`usersinfoTatoveringer_id`); -- -- Indexes for table `users_subscription` -- ALTER TABLE `users_subscription` ADD PRIMARY KEY (`usersSubscription_id`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `carousel1` -- ALTER TABLE `carousel1` MODIFY `carousel1_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `page_work1_videos` -- ALTER TABLE `page_work1_videos` MODIFY `pw1videos_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=51; -- -- AUTO_INCREMENT for table `users` -- ALTER TABLE `users` MODIFY `users_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11; -- -- AUTO_INCREMENT for table `users_files` -- ALTER TABLE `users_files` MODIFY `usersFiles_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT for table `users_gender` -- ALTER TABLE `users_gender` MODIFY `usersGender_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; -- -- AUTO_INCREMENT for table `users_info` -- ALTER TABLE `users_info` MODIFY `usersinfo_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2; -- -- AUTO_INCREMENT for table `users_info_bluse_storrelse` -- ALTER TABLE `users_info_bluse_storrelse` MODIFY `usersinfoBluseStorrelse_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `users_info_bukse_bredde` -- ALTER TABLE `users_info_bukse_bredde` MODIFY `usersinfoBukseBredde_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23; -- -- AUTO_INCREMENT for table `users_info_bukse_laengde` -- ALTER TABLE `users_info_bukse_laengde` MODIFY `usersinfoBukseLaengde_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26; -- -- AUTO_INCREMENT for table `users_info_etnicitet` -- ALTER TABLE `users_info_etnicitet` MODIFY `usersinfoEtnicitet_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `users_info_eye_color` -- ALTER TABLE `users_info_eye_color` MODIFY `usersinfoEyeColor_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `users_info_hair_color` -- ALTER TABLE `users_info_hair_color` MODIFY `usersinfoHairColor_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; -- -- AUTO_INCREMENT for table `users_info_kategorier` -- ALTER TABLE `users_info_kategorier` MODIFY `usersinfoKategorier_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10; -- -- AUTO_INCREMENT for table `users_info_landsdel` -- ALTER TABLE `users_info_landsdel` MODIFY `usersinfoLandsdel_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; -- -- AUTO_INCREMENT for table `users_info_sko_storrelse` -- ALTER TABLE `users_info_sko_storrelse` MODIFY `usersinfoSkoStorrelse_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=35; -- -- AUTO_INCREMENT for table `users_info_sprog` -- ALTER TABLE `users_info_sprog` MODIFY `usersinfoSprog_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8; -- -- AUTO_INCREMENT for table `users_info_tatoveringer` -- ALTER TABLE `users_info_tatoveringer` MODIFY `usersinfoTatoveringer_id` int(11) NOT NULL AUTO_INCREMENT; -- -- AUTO_INCREMENT for table `users_subscription` -- ALTER TABLE `users_subscription` MODIFY `usersSubscription_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; please note with this SQL, i have removed some names pre-made But that is my SQL never the less. Hoping you can help. And it is to my believes that it is with the queries my problems are, mainly, unsure about the if/else's statements, they look good to my eye, it is mostly the SQL i am not the best at making when it comes to searchers. Hope you can help, as always, thanks, and sorry if i left any info out. Please ask if you need more information! Thanks again!
  23. jonathanpecany

    Tutorials

    Suggestion 1: I had an idea for w3school for a very long time and this idea will help people learn better and even make school suggest it more. Add in a tutorial where people will have to figure how how to fix codes like it's almost like the try-it-out but you have to go through courses and learn programming through that, almost like khan academy almost except with programming except khan academy only teaches html and not PHP. And also it wouldn't hurt to show videos of how to understand PHP more. And also how to create websites like facebook and youtube and have interactive videos as well like khan academy and those interactive videos on there was actually cool, I was amazed of how they did that when I first learned html. W3school.com actually taught me more about html and CSS more than khan academy. I just hope this forum in connecting to the website I am talking about. But w3school did have a link to this forum so I am guessing so. Suggestion 2: Also I notice some websites has custom context menus and wondering if somehow they can teach how to create that as well because I tried searching how and had to program it and I looked at other websites and it was accurate and w3school shows more accurate html and CSS. Can it be added
  24. I'm learning php & sql. I can do the programming and logic, but how to put it all together is where I get confused. I have copied, from the w3 tutorial, the php form validation complete, and it worked fine. I have also used the php/sql database tutorial to copy the 'insert into' code and it works fine with a Db I set up on the local host. Now I would like to save the info in the form to a database table, but I'm not sure where to insert the code to connect to the database. I tried just adding the code at the bottom of the 'Form Complete' code but it didn't seem to take - no error codes but didn't get saved to the table. If I should keep it as a separate file, how and where do I call that file with the parameters I want to insert into the database? Is there anything on the w3 site that deals with this 'real life' situation. The tutorials are very good, but (everybody's got a big butt) the examples all use literals and they don't relate to a problem like I've explained here. I mean, why else would you have somebody fill in a form except to save the info in a table for future reference?? Any help going forward would be greatly appreciated. I didn't post the code here to save space, so if you're not sure what code I'm talking about, it's at w3schools and under PHP tutorial goto PHP forms 'Form Complete' and just below that in the SQL section is the code for Inserting data into a mySQL database. If I need to, I will post it. Thanx, Gil
  25. Hallo everyone. Thanks for a great website. I have been trying for a few days to get a safe, working php form that saves input to mysql. I have looked at several examples from different websites. The problem is that the form values are being stored to the database before the form validation process is complete. I have tried wrapping the process.php code in a function and only calling the function after the validation code is done and implemented some checks in a desperate attempt to resolve the matter using some global variables and a function that checks if the validation has done their work. But even with all this.. the user input is written to the database before validation is complete. for example.. if the user inputs his name with a preceding space, and submits the form, the preceding space ends up in the database. also a user can press the submit button multiple times and with every press, the information is stored to the database.. I imagine someone could write code to click that submit button millions of times until my server storage space runs out.. Any help would be much appreciated. Thanks. Einston I only have two files.. currently: 1: index.php and 2: testreqfields.php <html> <head> <title>Registration Form</title> </head> <body> <?php $inputisgood = false; $nameisgood = false; $surnameisgood = false; $emailisgood = false; $passwordisgood = false; include "testreqfields.php"; ?> <link href = "registration.css" type = "text/css" rel = "stylesheet" /> <h2>Sign Up</h2> <form name = "form1" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method = "post" enctype = "multipart/form-data" > <div class = "container"> <div class = "form_group"> <label>First Name:</label> <input type = "text" name = "name" value = "<?php echo $name;?>" required/> <span class="error">* <?php echo $nameErr;?></span> </div> <div class = "form_group"> <label>Surname:</label> <input type = "text" name = "surname" value = "<?php echo $surname;?>" required/> <span class="error">* <?php echo $surnameErr;?></span> </div> <div class = "form_group"> <label>Email:</label> <input type = "text" name = "email" value = "<?php echo $email;?>" required/> <span class="error">* <?php echo $emailErr;?></span> </div> <div class = "form_group"> <label>Password:</label> <input type = "password" name = "pwd" value = "<?php echo $pwd;?>" required/> <span class="error">* <?php echo $pwdErr;?></span> </div> <div class = "form_group"> <label>Gender:</label> <input type="radio" name="gender" value="female">Female <input type="radio" name="gender" value="female">Male </div> <input type = "submit" name = "enq_submit" value = "Submit" /> </div> </form> </body> </html> <?php function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } function sql_process() { //reset the global variable to be sure all code run again if there are errors in input. global $inputisgood; $inputisgood = false; //establish connection $servername = "localhost"; $config = parse_ini_file('../db_credentials/config.ini'); //create the connection $conn = mysqli_connect ($servername, $config['username'], $config['password'], $config['dbname']); //check connection if (!$conn){ die('Could not connect: ' . mysqli_connect_error()); } $sql = mysqli_select_db ($conn, $config['dbname']) or die("unable to connect to database"); //process if (isset($_POST['enq_submit'])){ $reg_name = $_POST['name']; $reg_surname = $_POST['surname']; $reg_email = $_POST['email']; $reg_pwd = $_POST['pwd']; $sql = "INSERT INTO registration (reg_name, reg_surname, reg_email, reg_pwd) VALUES ('$reg_name', '$reg_surname', '$reg_email', '$reg_pwd')"; echo("You have been signed up."); if (!mysqli_query($conn,$sql)){ die('Error: ' . mysqli_error($conn)); } } else { echo("Kindly use the form to sign up:"); }; } function ready_to_process () { global $nameisgood, $surnameisgood, $emailisgood, $passwordisgood, $inputisgood; if ($nameisgood) { echo ("##Name is good"); } if ($surnameisgood) { echo ("##Surnameame is good"); } if ($emailisgood) { echo ("##Email is good"); } if ($passwordisgood) { echo ("##Password is good"); } if ($nameisgood and $surnameisgood and $emailisgood and $passwordisgood) { echo ("##All input is good!"); $inputisgood = true; $nameisgood = $surnameisgood = $emailisgood = $passwordisgood = false; } } // define variables and set to empty values $nameErr = $surnameErr = $emailErr = $pwdErr = ""; $name = $surname = $email = $pwd = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Only letters and spaces allowed"; } else { $nameisgood = true; } } if (empty($_POST["surname"])) { $surnameErr = "Surname is required"; } else { $surname = test_input($_POST["surname"]); if (!preg_match("/^[a-zA-Z ]*$/",$surname)) { $surnameErr = "Only letters and spaces allowed"; } else { $surnameisgood = true; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format"; } else { $emailisgood = true; } } if (empty($_POST["pwd"])) { $pwdErr = "Password is required"; } else { $passwordisgood = true; } ready_to_process(); if ($inputisgood) { sql_process(); } } ?>
×