Jump to content

emcy

Members
  • Posts

    24
  • Joined

  • Last visited

emcy's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. emcy

    Responsive 5 columns?

    Hi, I have been searching on the w3 schools site for info on making a 5 column layout. I am guessing I have to make a two column and 3 column on the same row? Or is there another way to do it? Another thought I had was to make it 2 columns, 3 columns, 2 columns, 3 columns and 2 columns for the 12 column grid but that got really confusing. Can I just do w3-fifth instead of w3-quarter? Help please? Thanks B
  2. Dear ModeraterJustsomeguy, I would like to humbly request that the latter portion of this initial contact form page issue, about the mailinglist issue, be moved to a new topic. Would you please, kindly consider moving it over? I feel concerned about the two issues mixing in your search field, and the forum page getting tooooooo long and confusing for other info seekers. Thank you for taking the time and I hope you have a wonderful day (thanks tons for the help B
  3. HI, in the interest of this post about the contact form not being mixed up with my mailing list hover button/radio button issue.. how do I move my mailinglist topic question and your responses for it to another post? Thanks B
  4. emcy

    php NOT words?

    HI Thanks!.. ok Here is what I did.... This first part (blog.php) is for: 1. create the modal button on the page 2.when a user clicks on the button it opens up a modal asking for user ID and password 3.when the user enters his info and clicks submit.. it calls up the "include" file named blogpswdefineandcheck.php (see below blog.php) blog.php <!-- Button to open the modal login form --> <button onclick="document.getElementById('id01').style.display='block'">Login</button> <!-- The Modal --> <div id="id01" class="modal"> <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close Modal">×</span> <!-- Modal Content --> <?php> ini_set('display_errors', 1); error_reporting(E_ALL); include('blogpswdefineandcheck.php'); function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <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="../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> </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> 4. It checks the users input against the hardcoded username and password 5. If the user name and password match, then it shows a link for the blogentriespage.php blogpswdefineandcheck.php <?php define("uname", "me" . "psw", "mypsw"); function myTest($uname, $psw) { //this $uname and $psw will come from the user's input in the form if ($uname == me and $psw == mypsw) { echo "Hi Me! Welcome Back!"; echo '<a href="http://www.me.com/xmas/blongentriespage.php">Click here to access the blog entries page</a>'; } else { echo "Have a good night! You are NOT me!"; } } myTest(); ?> 7. The next part is for the bottom part of the blog.php page where it shows all the other entries by linked categories (i.e. Year, Month, Title) for the user to select a. first it connects to the database via an included (blogdbConfig.php) b. then it seeks the columns of year, month and title c. then it creates the links to those column's on the blog.php page (right in that section of the page), for the user to choose from d. when the user clicks on year, month or title.. it returns the list of all the entries in that column, in a pretty way on the screen in that same section area <?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 // Check connection if ($connect->connect_error) { die("Connection failed: " . myseqli_connect_error()); } $mysqli = "SELECT id, date, title, content FROM myblog"; $result = $connect->query($mysqli); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> id: ". $row["id"]. "Date: ". $row["date"]. "Title " . $row["Title"] . "<br>"; echo "Content: " . $row["content"] . "<br>"; } } else { echo "0 results"; } $connect->close(); ?> 8. On the blogentriespage.php I used my code from my contact page on this (also used my blogdbConfig.php)..... <?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); // 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 // 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 $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) $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 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; // 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 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>"; // 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); ?> I think that's all I need?.. but it still sort of doesn't work.. ideas? What I now get is: 1. The pop up window /modal for entering a username and password comes up , and I enter my information but then when I click on submit, it disappears and does not open the blogentries page 2. I get this error message: Notice: Trying to get property of non-object in /homepages/42//htdocs/xmas/blog.php on line 2230 results Search the blog for particular dates and entries 3. There are no links above as you can see... only the title"Search the blog for particular dates and entries". hmm. ideas? Here is what line 223 is in blog.php <?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 // Check connection if ($connect->connect_error) { die("Connection failed: " . myseqli_connect_error()); } $mysqli = "SELECT id, date, title, content FROM myblog"; $result = $connect->query($mysqli); //line 223 if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { echo "<br> id: ". $row["id"]. "Date: ". $row["date"]. "Title " . $row["Title"] . "<br>"; echo "Content: " . $row["content"] . "<br>"; } } else { echo "0 results"; } $connect->close(); ?> <hr> <p>Search the blog for particular dates and entries</p> Thanks B
  5. 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
  6. Hi, No, This is what I want to do but haven't found a way to do it with AJAX yet... 1. when a user gets to the point of selecting yes or no for the mailing list..... a. if he clicks the "yes" radio button, it will drop down a box where he can select from a number of mailing lists (checkboxes), and that information gets held onto until he clicks"submit" for the entire form 2. Once he clicks submit on the form page, the information goes to these places: a. an email of the information goes to me b. an email copy of the info goes to the user c. all the information with each mailing list selected goes into the mailinglist database d. all the information with just a yes/no for the mailinglist question goes to the contactform database e. all the info the user entered and the mailinglists he selected gets printed on his browser window with a "success" message I tried to figure it out in AJAX, but... I can't see how to create the checkboxes in there . It seems like its more for static information, not interactivity. other ideas? or did I miss something? THanks B
  7. HI OK .. am processing.. .... I have a php page which contains my form. at one point I have this piece of code....... if (empty($_POST["join_mailing_list"])) { $join_mailing_listErr = "requires a yes or no"; $passed = false; } else { $join_mailing_list = test_input($_POST["join_mailing_list"]); } $first_nameErr = $last_nameErr = $phone_numberErr = $addressErr = $cityErr = $stateErr = $zipErr = $countryErr = $email_addressErr = $commentsErr = $everylistErr = $list1Err = $list2Err = $list3Err = $list4Err = $list5Err = $list6Err = $list7Err = $list8Err = $list9Err = $list10Err = $list11Err = ""; $first_name = $last_name = $phone_number = $address = $city = $state = $zip = $country = $email_address = $comments = $everylist = $list1 = $list2 = $list3 = $list4 = $list5 = $list6 = $list7 = $list8 = $list9 = $list10 = $list11 = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { // if connected to the server successfully and it requests info or is ready to receive the info.... $passed = true; $everylist = test_input($_POST["everylist"]); $list1 = test_input($_POST["list1"]); $list2 = test_input($_POST["list2"]); $list3 = test_input($_POST["list3"]); $list4 = test_input($_POST["list4"]); $list5 = test_input($_POST["list5"]); $list6 = test_input($_POST["list6"]); $list7 = test_input($_POST["list7"]); $list8 = test_input($_POST["list8"]); $list9 = test_input($_POST["list9"]); $list10 = test_input($_POST["list10"]); $list11 = test_input($_POST["list11"]); if ($passed) { $mysqli = "INSERT INTO mailinglist (first_name, last_name, phone_number, address, city, state, zip, country, email_address, comments, everylist, list1, list2, list3, list4, list5, list6, list7, list8, list9, list10, list11) VALUES ('$first_name','$last_name','$phone_number','$address','$city','$state','$zip','$country','$email_address', '$comments','$everylist','$list1','$list2','$list3','$list4','$list5','$list6','$list7','$list8','$list9','$list10','$list11])"; if (mysqli_query($connect, $mysqli)) { echo "New record created successfully"; } else { echo "Error: " . $mysqli . "<br>" . mysqli_error($connect); } $email = "info@mygmail.com"; $emailSubject = "Inquiry from the contact page with Newsletter signup"; // define what the headers of the email should say $headers = "From:$email_address\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> First Name : $first_name <br> Last Name : $last_name <br> Phone Number : $phone_number <br> Address : $address <br> City : $city <br> State : $state <br> Zip : $zip <br> Country : $country <br> Email Address : $email_address <br> Comments : $comments <br> You have subscribed to the following Newsletters : // how do I show which ones here?<br> <br> EOD; echo "<h2>Thank you your message was received successfully. Here is a copy of what you sent us:</h2>"; echo "First Name: " . $first_name . "<br>"; echo "Last Name: " . $last_name . "<br>"; echo "Phone Number: " . $phone_number . "<br>"; echo "Address: " . $address . "<br>"; echo "City: " . $city . "<br>"; echo "State: " . $state . "<br>"; echo "Zip Code: " . $zip . "<br>"; echo "Country: " . $country . "<br>"; echo "Email Address: " . $email_address . "<br>"; echo "Comments: " . $comments . "<br>"; echo "Joined The following Mailing lists: " . // $how do I show which ones here?; $first_name = $last_name = $phone_number = $address = $city = $state = $zip = $country = $email_address = $comments = $everylist = $list1 = $list2 = $list3 = $list4 = $list5 = $list6 = $list7 = $list8 = $list9 = $list10 = $list11 = ""; } } //$mailinglistdatabase = //$first_name','$last_name','$phone_number','$address','$city','$state','$zip','$country','$email_address', //$comments','one',two','three','four' // The form's html code would go in here? // define variables as per what the user has entered on the page I thought, but am told I don't need these so will try to go without. :) // $first_name = $_POST['first_name']; // $last_name = $_POST['last_name']; // $phone_number = $_POST['phone_number']; // $address = $_POST['address']; // $city = $_POST['city']; // $state = $_POST['state']; // $zip = $_POST['zip']; // $email_address = $_POST['email_address']; // $country = $_POST['country']; // $comments = $_POST['comments']; // $join_mailing_list = $_POST['join_mailing_list']; // $name=$_POST['name']; ?> Do I insert the AJAX as below in place of the above coding? i.e. <div id="mailinglists"> <h2>Signup for our mailinglists</h2> <button type="button" onclick="loadDoc()">show a selection for them to click on and open the boxes</button> </div> where loadDoc opens a file called "mailinglist" which is the .txt file? and <script> function loadDoc() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("demo").innerHTML = this.responseText; } }; xhttp.open("GET", "mailinglist.txt", true); xhttp.send(); } </script> (do I need to change GET to POST for security reasons?) and mailinglist.txt is an xml file that looks like this:? everylist list1 list2 list3 list4 list5 list6 list7 list8 list9 list10 list11 But how do I get the pretty little check boxes for the user to click them open if this is a text file? Do I need to make it a little php file of it's own to execute at the same time the greater php file executes on submit? thanks
  8. OK.. looks like I have tons more work to do on this... am going into research mode on w3schools forum to learn about AJAX and declaring the function twice in a php form. Thanks.. will check back in soon... Hope you all have a great day B
  9. ok.. Just changed the phone number field to "Varchar" since it gave me an error message when I tried to change it to text. I'm guessing that's a similar thing like "text", and it will still be stripped of unwanted characters by the php function before insertion.
  10. Wow! Cool ! You just "up-sold" me on having to learn AJAX now too LOL!!! Thanks.. I think ?!?!?!?! So Far I have the page looking right on the user's side. The hover drop down button looks pretty However when I hit submit I get and error message: Fatal error: Cannot redeclare test_input() (previously declared in /homepages/42/d547303762/htdocs/w/contactus.php:121) in /homepages/42/d547303762/htdocs/w/contactus.php on line 258 SO.. I will look into AJAX and javascript. THanks
  11. Ok.. am just processing thoughts here in english to get to the php codeing of it.....Am open to your suggestions please 1. Php If/else statement: If the user clicks on the "yes" radio button, then a hoverable-drop-down-menu opens up with a selection of checkboxes for which list to sign up for My attempt at html multi-selection-hoverable-drop-down-button: .....<input class="w3-radio" type="radio" name="join_mailing_list" <?php if (isset($join_mailing_list) && $join_mailing_list == "yes") echo "checked"; ?> value="yes"> <div class="dropdown"> <button onclick="myFunction()" class="dropbtn">Yes</button> <div class="dropdown-content"> <label class="container">All Lists <input type="checkbox" checked="checked" value'"All LIsts"> <span class="checkmark"></span> </label> <label class="container">one <input type="checkbox" value="one"> <span class="checkmark"></span> </label> <label class="container">two <input type="checkbox" value="two"> <span class="checkmark"></span> </label> <label class="container">three <input type="checkbox" value="three"> <span class="checkmark"></span> </label> <label class="container">four <input type="checkbox" value="four"> <span class="checkmark"></span> </label> </div> </div> My Attempt at the Php code for it: // This would be added to Section C from my previous messages above // this is already in the page // if (empty($_POST["join_mailing_list"])) { // $join_mailing_listErr = "requires a yes or no"; // $passed = false; // } else { // $join_mailing_list = test_input($_POST["join_mailing_list"]); // . }" // Here I am adding the extra new code.. some of which seems like the same thing put in here but twice (since I copied it from the php code above to re-enter it for to send the same info to the second database).... // I want to tell it....if value="yes", then "on submit", send the page information to two databases. // The first database ($database) gets all the information and "joining_the_mailinglist" is shown as yes or no ... this already is set up and works. This is done via my "Configfile.php" which is set up as an "include" in the contact form at the top. // The second database ($mailinglistdatabase?) gets all the information plus the checked boxes of mailing lists selected. // so....can I be connected to two databases at one time to do this? or how do I work this the best? Do I close the first one first, then re-send the info to the second database using similar php coding to include all the info from the form plus more? include('dbConfigmailinglist#2signininfo.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; } $first_nameErr = $last_nameErr = $phone_numberErr = $addressErr = $cityErr = $stateErr = $zipErr = $countryErr = $email_addressErr = $commentsErr = $join_mailing_listErr = ""; $first_name = $last_name = $phone_number = $address = $city = $state = $zip = $country = $email_address = $comments = $one = $two = $three = $four = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { // if connected to the server successfully and it requests info or is ready to receive the info.... $passed = true; if (empty$_POST["join_mailing_list"])) { $join_mailing_listErr = "requires a yes or no"; $passed = false; } else { $join_mailing_list = test_input($_POST["join_mailing_list"]); } if ($passed) { $mysqli = "INSERT INTO mailinglistdatabases (first_name, last_name, phone_number, address, city, state, zip, country, email_address, comments, one, two, three, four) VALUES ('$first_name','$last_name','$phone_number','$address','$city','$state','$zip','$country','$email_address', '$comments','$one','$two','$three','$four')"; if (mysqli_query($connect, $mysqli)) { echo "New record created successfully"; } else { echo "Error: " . $mysqli . "<br>" . mysqli_error($connect); } $email = "info@myemail.com"; $emailSubject = "Inquiry from the contact page with Newsletter signup"; // define what the headers of the email should say $headers = "From:$email_address\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> First Name : $first_name <br> Last Name : $last_name <br> Phone Number : $phone_number <br> Address : $address <br> City : $city <br> State : $state <br> Zip : $zip <br> Country : $country <br> Email Address : $email_address <br> Comments : $comments <br> You subscribed to the following Newsletters : // how do I show which ones here?<br> <br> EOD; echo "<h2>Thank you your message was received successfully. Here is a copy of what you sent us:</h2>"; echo "First Name: " . $first_name . "<br>"; echo "Last Name: " . $last_name . "<br>"; echo "Phone Number: " . $phone_number . "<br>"; echo "Address: " . $address . "<br>"; echo "City: " . $city . "<br>"; echo "State: " . $state . "<br>"; echo "Zip Code: " . $zip . "<br>"; echo "Country: " . $country . "<br>"; echo "Email Address: " . $email_address . "<br>"; echo "Comments: " . $comments . "<br>"; echo "Joined The following Mailing lists: " . // $how do I show which ones here?; $first_name = $last_name = $phone_number = $address = $city = $state = $zip = $country = $email_address = $comments = $one = $two = $three = $four = ""; } } ?> $mailinglistdatabase = $first_name','$last_name','$phone_number','$address','$city','$state','$zip','$country','$email_address', '$comments','one',two','three','four' // The form's html code would go in here? <form></form> Issues: do I need to define a new $variable here for the entire page of info? to send to the "mailinglist" database? , or perhaps use another "Insert Into" statement for the second database? Is it possible to nest "Insert Into" statements? Is it possible to nest "include" statements for two databases? Thanks B
  12. Oh one more question...... I am also building a mailinglist page in php. On the contact page as the last choice for the user, I give them the option to elect yes or no if they want to sign up for the mailing list. I would like to make it so that: 1) if the user selects yes, that it will present a drop down menu to select which list they want to sign up on (I have about 8) - Because I am working with php and html, I am a bit confused... can I simply create a drop down menu in html, and then in php add an" if/else" statement so that the menu is hidden until they select yes? I feel like I'm missing a piece here... how to hide the menu until "yes" is selected? Or do I need to use Php object rules?, or.....I found a new one on the w3 schools forum about...PHP resource! That sounds like it might be able to put the info into the other database.. ugh! So many options! LOL! 2) How do I send all the information from the contact page to the mailing list database (which is a separate database from teh contactpage database) only when the user selects a mailing list? 3) How to make it "echo" back on the page which mailing lists they signed up for ( more than one hopefully) Thanks
  13. oh I have one more issue... When the user enters the phone number it shows up wrong in the database... i.e. when a dash is entered between the numbers 224-578-9562, then only the 224 shows up in teh database. when I leave the dashes out, it shows up as a completely different number 2147483671 . (there are enough digits in this but it's not the number the user entered... I am guessing this is because I have no error testing set up on the phone number in the php form? I also have the function to strip out hash marks and other characters I don't want. .so how do I specify that for phone numbers it's ok to accept dashes, and how do I make it also give the correct number if the user chooses not to enter dashes? Thanks
  14. Yes! Thank you! That's it! I had it set to Tiny Int (1). I am still new to mysqli and have studied the w3schools pages but still have more to learn . Thank you!!!!! Where can I send you a coffee? Peace B
  15. Hmmm.. I think I wasn't clear in my statement before... It doesn't matter which radio button is chosen, the database field for both yes and no are entered with zeros, both, each time. so I have no way to differentiate if it's a yes or no that the user has entered.
×
×
  • Create New...