Jump to content

mroberts46

Members
  • Posts

    60
  • Joined

  • Last visited

About mroberts46

  • Birthday 11/01/1986

Contact Methods

  • MSN
    mroberts4@live.seminolestate.edu
  • Website URL
    http://www.phantomdevelopment.netai.net
  • Yahoo
    bones_oneal

Profile Information

  • Gender
    Male
  • Location
    FL

mroberts46's Achievements

Member

Member (2/5)

0

Reputation

  1. I'm trying to do one of two things (whichever I get to work first): Create a form that both submits the data by email AND redirects user to a different page, OR modify a PayPal Buy Now button to request the additional data and have it emailed to the client. The code below is one of many attempts at creating an email form that redirects to another page containing the PayPal button. Can someone please give me some pointers? This is before the doctype tag: <?php $fName = $_POST['fName']; $lName = $_POST['lName']; $email = $_POST['email']; $cEmail = $_POST['cEmail']; $phone = $_POST['tele']; $pickUp = $_POST['pickUp']; $dropOff = $_POST['dropOff']; $date = $_POST['date']; $service = $_POST['service']; $instruct = $_POST['instruct']; $human = $_POST['human']; $thankyou = 'thankyou.htm'; $from = 'From: Joyful Xpressions'; $to = 'feliciaharried@yahoo.com'; $subject = 'Service Request'; $body = "From: $fName $lName\n E-Mail: $email\n Phone: $phone\n \n Pick Up Location: $pickUp\n Drop Off Location: $dropOff\n Pick Up Date: $date\n \n Service Requested: $service\n \n Special Instructions: $instruct"; ?> This is the form: <form action="service.php https://www.paypal.com/cgi-bin/webscr" method="post" name="register" target="_top" onSubmit="document.location='thankyou.htm';"> <h2>Register</h2> <p>Give us a try! Use this form to sign up for your first FREE pick up. Enter your information below and submit. You will get a Paypal button which allows you to select the service you want and proceed to Paypal's secure payment page to process your payment. You may be asked to enter some information again.</p> <hr/> <fieldset> <legend>Personal Information</legend> <label for="fName">First Name: </label> <input autocomplete="on" autofocus name="fName" placeholder="First Name" required type="text" /> <br/> <label for="lName">Last Name: </label> <input autocomplete="on" name="lName" placeholder="Last Name" required type="text" /> <br/> <label for="email">Email: </label> <input autocomplete="on" name="email" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="cEmail">Confirm Email: </label> <input autocomplete="off" name="cEmail" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="tele">Phone: </label> <input autocomplete="on" name="tele" placeholder="555-555-5555" required type="tel" /> </fieldset> <br/> <br/> <fieldset> <legend>Service Request</legend> <label for="pickUp">Complete Address for Pickup: </label> <textarea cols="20" name="pickUp" placeholder="Please enter your desired pickup location." required rows="3"></textarea> <br/> <label for="dropOff">Complete Address for Delivery: </label> <textarea cols="20" name="dropOff" placeholder="Please enter your desired drop off location." required rows="3"></textarea> <br/> <label for="date">Pickup Date: </label> <input autocomplete="off" min="2013-01-01" name="date" required type="date" /> <br/> <label for="service">Chore: </label> <select name="service"> <option value="1 Bag">1 Bag $35.00 USD</option> <option value="2 Bags">2 Bags $65.00 USD</option> <option value="Express Service">Express Service $15.00 USD</option> <option value="King Comforter">King Comforter $20.00 USD</option> <option value="Queen Comforter">Queen Comforter $15.00 USD</option> </select> <br/> </fieldset> <br/> <br/> <fieldset> <legend>Special Intructions</legend> <textarea cols="70" name="instruct" placeholder="Please enter any special instructions you may have regarding your service request here." rows="10"></textarea> <br/> </fieldset> <br/> <br/> <fieldset> <label>*What is 2+2? (Anti-spam)</label> <input name="human" placeholder="Type Here"> <br/> <br/> <input type="hidden" name="return" value="http://expressyourchores.com/thankyou.htm" /> <input id="submit" type="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" /> </fieldset> <br/> <? if ($_POST['submit'] && $human == '4') { if (mail ($to, $subject, $body, $from)) { echo '<p>Test Failed</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; } ?> </form> How can I modify this form to redirect to the PayPal button page?
  2. I have been working on this website for a client. One of the features this client requires is the ability to pay for services via PayPal. They have created a Buy Now button and submitted to me the code from said button. The client would also like for some additional information not needed by PayPal to be emailed to them. Currently my form code looks like this: <form action="service.php" method="post" name="register" onSubmit="document.location='thankyou.htm';"> <?php $fName = $_POST['fName']; $lName = $_POST['lName']; $email = $_POST['email']; $cEmail = $_POST['cEmail']; $phone = $_POST['tele']; $pickUp = $_POST['pickUp']; $dropOff = $_POST['dropOff']; $date = $_POST['date']; $service = $_POST['service']; $instruct = $_POST['instruct']; $human = $_POST['human']; $thankyou = 'thankyou.htm'; $from = 'From: Joyful Xpressions'; $to = 'feliciaharried@yahoo.com'; $subject = 'Service Request'; $body = "From: $fName $lName\n E-Mail: $email\n Phone: $phone\n \n Pick Up Location: $pickUp\n Drop Off Location: $dropOff\n Pick Up Date: $date\n \n Service Requested: $service\n \n Special Instructions: $instruct"; ?> <h2>Register</h2> <p>Give us a try! Use this form to sign up for your first FREE pick up. Enter your information below and submit. You will get a Paypal button which allows you to select the service you want and proceed to Paypal's secure payment page to process your payment. You may be asked to enter some information again.</p> <hr/> <fieldset> <legend>Personal Information</legend> <label for="fName">First Name: </label> <input autocomplete="on" autofocus name="fName" placeholder="First Name" required type="text" /> <br/> <label for="lName">Last Name: </label> <input autocomplete="on" name="lName" placeholder="Last Name" required type="text" /> <br/> <label for="email">Email: </label> <input autocomplete="on" name="email" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="cEmail">Confirm Email: </label> <input autocomplete="off" name="cEmail" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="tele">Phone: </label> <input autocomplete="on" name="tele" placeholder="555-555-5555" required type="tel" /> </fieldset> <br/> <br/> <fieldset> <legend>Service Request</legend> <label for="pickUp">Complete Address for Pickup: </label> <textarea cols="20" name="pickUp" placeholder="Please enter your desired pickup location." required rows="3"></textarea> <br/> <label for="dropOff">Complete Address for Delivery: </label> <textarea cols="20" name="dropOff" placeholder="Please enter your desired drop off location." required rows="3"></textarea> <br/> <label for="date">Pickup Date: </label> <input autocomplete="off" min="2013-01-01" name="date" required type="date" /> <br/> <label for="service">Chore: </label> <select name="service"> <option value="1 Bag">1 Bag $35.00 USD</option> <option value="2 Bags">2 Bags $65.00 USD</option> <option value="Express Service">Express Service $15.00 USD</option> <option value="King Comforter">King Comforter $20.00 USD</option> <option value="Queen Comforter">Queen Comforter $15.00 USD</option> </select> <br/> </fieldset> <br/> <br/> <fieldset> <legend>Special Intructions</legend> <textarea cols="70" name="instruct" placeholder="Please enter any special instructions you may have regarding your service request here." rows="10"></textarea> <br/> </fieldset> <br/> <br/> <fieldset> <label>*What is 2+2? (Anti-spam)</label> <input name="human" placeholder="Type Here"> <br/> <br/> <input type="hidden" name="return" value="http://expressyourchores.com/thankyou.htm" /> <input id="submit" type="submit" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" /> </fieldset> <br/> <? if ($_POST['submit'] && $human == '4') { if (mail ($to, $subject, $body, $from)) { echo '<p>Test Failed</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; } ?> </form> I have tried several different methods of submitting the email the redirecting to a Thank You page which contains the PayPal Buy Now button form. and none of my redirects have worked. I have also scoured the internet looking for ways to complete both tasks through one form and have come up with nothing. The PayPal button form looks like this: <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top"> <input type="hidden" name="cmd" value="_s-xclick" /> <input type="hidden" name="hosted_button_id" value="VPK6MXG9XGY6L" /> <table> <tr> <td><input type="hidden" name="on0" value="Chores" /> Chores</td> </tr> <tr> <td><select name="os0"> <option value="1 Bag">1 Bag $35.00 USD</option> <option value="2 Bags">2 Bags $65.00 USD</option> <option value="Express Service">Express Service $15.00 USD</option> <option value="King Comforter">King Comforter $20.00 USD</option> <option value="Queen Comforter">Queen Comforter $15.00 USD</option> </select></td> </tr> </table> <input type="hidden" name="currency_code" value="USD" /> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" /> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" /> </form> Is there any way to combine the two and accomplish both tasks through one form? If not, how could I rewrite the first form's code to redirect to the Thank You page that has the PayPal button? This project has done nothing but make me more and more frustrated. Please note that the variables and email format php code in the first form was moved into the form to place on here. Originally, that code was placed before the doctype of the page. I hope that someone can actually assist me in making this form work as it's the only thing preventing me from turning the project over to the client.
  3. Hoping someone will help me with my latest topic.

  4. This has been bugging me for over a week now. I am admittedly a newbie with php but I think this shouldn't be that hard. Below is the code from my page. I need it to redirect to another page called thankyou.htm where the user will get a Thank You message and a PayPal button to pay for the services they have selected. I can't get this code to do the redirect and I've tried it several different ways. Can somebody please help me solve this issue quickly? The Code: <?php $fName = $_POST['fName']; $lName = $_POST['lName']; $email = $_POST['email']; $cEmail = $_POST['cEmail']; $phone = $_POST['tele']; $pickUp = $_POST['pickUp']; $dropOff = $_POST['dropOff']; $date = $_POST['date']; $service = $_POST['service']; $instruct = $_POST['instruct']; $human = $_POST['human']; $thankyou = 'thankyou.htm'; $from = 'From: Joyful Xpressions'; $to = 'example@sample.com'; $subject = 'Service Request'; $body = "From: $fName $lName\n E-Mail: $email\n Phone: $phone\n \n Pick Up Location: $pickUp\n Drop Off Location: $dropOff\n Pick Up Date: $date\n \n Service Requested: $service\n \n Special Instructions: $instruct"; ?> <!doctype html> <html class="no-js"> <!-- InstanceBegin template="/Templates/main.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta name="description" content="We do the washing and folding while you focus on the busy activities in everyday life."> <meta name="keywords" content="Joyful,Xpressions,washing,folding,laundry,Dallas,pick up"> <meta name="author" content="Harried Enterprises"> <meta charset="utf-8"> <!-- InstanceBeginEditable name="doctitle" --> <title>Joyful Xpressions CRegister</title> <!-- InstanceEndEditable --> <link href="Resources/Styles/layout.css" media="screen" rel="stylesheet" type="text/css" /> <script type="text/javascript"> $(function() { if ($.browser.msie && $.browser.version.substr(0,1)<7) { $('li').has('ul').mouseover(function(){ $(this).children('ul').css('visibility','visible'); }).mouseout(function(){ $(this).children('ul').css('visibility','hidden'); }) } }); </script> <script src="//use.edgefonts.net/nosifer:n4:all;muli:n3,i3,n4,i4:all.js"></script> <!--[if lt IE 9]> <script src="dist/html5shiv.js"></script> <![endif]--> <!-- InstanceBeginEditable name="head" --> <!-- InstanceEndEditable --> </head> <body> <div id="wrapper"> <header> <img src="Resources/Images/header.png" alt="Joyful Xpressions Logo" width="960" height="150" /> <ul id="menu"> <li><a href="index.htm">Home</a></li> <li> <a href="#">About Us</a> <ul> <li><a href="company.htm">Our Company</a></li> <li><a href="services.htm">Our Services</a></li> <li><a href="questions.htm">FAQ</a></li> </ul> </li> <li><a href="contact.htm">Contact</a></li> </ul> <div class="clear"> </div> </header> <div class="clear"> </div> <section id="content"> <!-- InstanceBeginEditable name="mainContent" --> <form action="service.php" method="post" name="register" onSubmit="document.location='thankyou.htm';"> <h2>Register</h2> <p>Give us a try! Use this form to sign up for your first FREE pick up. Enter your information below and submit. You will get a Paypal button which allows you to select the service you want and proceed to Paypal's secure payment page to process your payment. You may be asked to enter some information again.</p> <hr/> <fieldset> <legend>Personal Information</legend> <label for="fName">First Name: </label> <input autocomplete="on" autofocus name="fName" placeholder="First Name" required type="text" /> <br/> <label for="lName">Last Name: </label> <input autocomplete="on" name="lName" placeholder="Last Name" required type="text" /> <br/> <label for="email">Email: </label> <input autocomplete="on" name="email" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="cEmail">Confirm Email: </label> <input autocomplete="off" name="cEmail" placeholder="john.doe@example.com" required type="email" /> <br/> <label for="tele">Phone: </label> <input autocomplete="on" name="tele" placeholder="555-555-5555" required type="tel" /> </fieldset> <br/> <br/> <fieldset> <legend>Service Request</legend> <label for="pickUp">Complete Address for Pickup: </label> <textarea cols="20" name="pickUp" placeholder="Please enter your desired pickup location." required rows="3"></textarea> <br/> <label for="dropOff">Complete Address for Delivery: </label> <textarea cols="20" name="dropOff" placeholder="Please enter your desired drop off location." required rows="3"></textarea> <br/> <label for="date">Pickup Date: </label> <input autocomplete="off" min="2013-01-01" name="date" required type="date" /> <br/> <label for="service">Chore: </label> <select name="service"> <option value="1 Bag">1 Bag $35.00 USD</option> <option value="2 Bags">2 Bags $65.00 USD</option> <option value="Express Service">Express Service $15.00 USD</option> <option value="King Comforter">King Comforter $20.00 USD</option> <option value="Queen Comforter">Queen Comforter $15.00 USD</option> </select> <br/> </fieldset> <br/> <br/> <fieldset> <legend>Special Intructions</legend> <textarea cols="70" name="instruct" placeholder="Please enter any special instructions you may have regarding your service request here." rows="10"></textarea> <br/> </fieldset> <br/> <br/> <fieldset> <label>*What is 2+2? (Anti-spam)</label> <input name="human" placeholder="Type Here"> <br/> <br/> <input id="submit" name="submit" type="submit" value="Submit Information"> </fieldset> <br/> <? if ($_POST['submit'] && $human == '4') { if (mail ($to, $subject, $body, $from)) { header ("Location: http://www.expressyourchores.com/thankyou.htm"); echo '<p>Your message has been sent!</p>'; } else { echo '<p>Something went wrong, go back and try again!</p>'; } } else if ($_POST['submit'] && $human != '4') { echo '<p>You answered the anti-spam question incorrectly!</p>'; } ?> </form> PLEASE HELP!!!
  5. When I changed it from 'id' to 'user_id' I made the change across the site, not to just one page.
  6. Before I created the index2.php page, I had to refresh the page after loging out in order to get the login form back. Redirecting to index2.php seemed to fix that issue until I can figure out how to get it to work redirecting back to index.php without refreshing.
  7. For a temporary fix, I have found that redirecting to a different file (index2.php allows me to log in and out without refreshing the page. One known issue is that on index.php the logged in info still shows until you refresh the page. For now, though, I feel I can move on a little bit further.
  8. Also, I un-commented the error_reporting line in init.php and changed it to error_reporting(-1) and ran the page, ran through the logging in and out process, and got no errors. I did the same thing after changing the line to error_reporting(E_NOTICE) and got nothing. If there is no error or notices then why must I refresh the page in order to have the changes be reflected? In the last post in which I posted code, I supplied all of the included files with the exception of the files that only contained HTML code. In index.php, includes/overall/footer.php contains includes/footer.php (which is completely blank) and the closing body and html tags. overall/header.php contains includes/head.php (<head>, meta tags, link to stylesheet, link to jquery and modernizr scripts, and two modernizr tweaking scripts, </head>), includes/header.php (open body tag, logo, includes/navigation.php (just ul navigation)) Everything else is listed up there. The only other page I created is called register.php but since I haven't made it to that yet I'm using the content area to display phpinfo(). if you want to see for yourself the way the silly thing is behaving, go to: http://alcornalumnaedst.org/new_site/testing/index.php. I'll create an account for username(test) password(test).
  9. Yes. I just ran the page again and was able to log in and out. However, this test was done only on one page (index.php) and I had to refresh the page in order to see the login form again. When I tried logging in and changing to another page, I had to refresh the page to see that I was logged in. Same thing with logging out. If I click Log Out for a second time without refreshing the page first, when I do refresh the page, I am still logged in. How do I fix this?
  10. I following along with a video tutorial series on creating an Admin/Login/Registration System. The series is 44 videos long but I'm just on video 13. I have broken down index.php into smaller files that are included as needed. I there were some way to send or post the zip file you'd be better able to see the file structure. Of course doing it this way causes a major headache when debugging. index.php: <?php include 'core/init.php'; include 'includes/overall/header.php'; ?> <div id="container"> <section id="slider"> </section> <?php include 'includes/aside.php'; ?> <section id="content"> <header> <hgroup> <h1>Welcome</h1> <h2>to the official website of the Alcorn Alumnae Chapter (Lorman, MS) of Delta Sigma Theta Sorority, Incorporated.</h2> </hgroup> </header> <p class="dropcaps">The Alcorn Alumnae Chapter of Delta Sigma Theta Sorority, Incorporated was chartered in February of 1960 by fourteen (14) college educated women. Their mission was to provide constructive development of its members and to provide service to the communities of Claiborne and Jefferson Counties in southwest Mississippi. That mission continues today as we partner with various community-based organizations to provide programs and services beneficial to our primary service areas.</p> <hr /> <figure style="float: left;"> <a href="http://www.deltasigmatheta.org/home.htm"> <img alt="Delta Sigma Theta Corporate Homepage" src="resources/images/corporate.png" style="height: 125px;" /></a> <figcaption> <p><a href="http://www.deltasigmatheta.org/home.htm">Corporate Site</a><br /> <small>Visit our corporate site</small></p> </figcaption> </figure> <figure style="float: left;"> <a href="http://www.deltasigmatheta.org/centennial/index.htm"> <img alt="Delta Sigma Theta Centennial Site" src="resources/images/centennial.png" style="height: 125px;" /></a> <figcaption> <p> <a href="http://www.deltasigmatheta.org/centennial/index.htm"> Centennial Site</a><br /> <small>Celebrating our rich history</small></p> </figcaption> </figure> <figure style="float: left;"> <a href="http://thewomengather.com/"> <img alt="Delta Sigma Theta International Conference Homepage" src="resources/images/international-conference.png" style="height: 125px;" /> </a> <figcaption> <p><a href="http://thewomengather.com/">International Conference</a><br /> <small>Secrets Breaking The Culture of Silence</small></p> </figcaption> </figure> </section> <div style="clear:both"></div> </div> <?php include 'includes/overall/footer.php'; ?> core/init.php: <?php session_start(); //error_reporting(0); require 'database/connect.php'; require 'functions/general.php'; require 'functions/users.php'; if (logged_in() === true) { $session_user_id = $_SESSION{'id'}; $user_data = user_data($session_user_id, 'id', 'username', 'password', 'first', 'last', 'email'); if (user_active($user_data['username']) === false) { session_destroy(); header('Location: index.php'); exit(); } } $errors = array(); ?> functions/general.php: <?php function sanitize($data) { return mysql_real_escape_string($data); } function output_errors($errors) { $output = array(); foreach($errors as $error) { $output[] = '<li>' . $error . '</li>'; } return '<ul>' . implode('', $output) . '</ul>'; } ?> functions/users.php: <?php function user_data($user_id) { $data = array(); $user_id = (int)$user_id; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if ($func_num_args > 1) { unset($func_get_args[0]); $fields = '`' . implode('`, `', $func_get_args) . '`'; $data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `user` WHERE `id` = '$user_id'")); } return $data; } function logged_in() { return (isset($_SESSION['user_id'])) ? true : false; } function user_exists($username) { $username = sanitize($username); return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user` WHERE `username` = '$username'"), 0) == 1) ? true : false; } function user_active($username) { $username = sanitize($username); return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user` WHERE `username` = '$username' AND `active` = 1"), 0) == 1) ? true : false; } function user_id_from_username($username) { $username = sanitize($username); return mysql_result(mysql_query("SELECT `id` FROM `user` WHERE `username` = '$username'"), 0, 'id'); } function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false; } ?> overall/header.php: <!DOCTYPE HTML> <html> <?php include 'includes/head.php'; ?> <body> <?php include 'includes/header.php'; ?> This just the <head> section of the html and the masthead of the page along with the main menu. No php code in any of the included files here. All HTML. includes/aside.php: <aside id="sidebar"> <aside class="widgets"> <?php if (logged_in() === false) { include 'includes/widgets/login.php'; } else if (logged_in() === true) { include 'includes/widgets/loggedin.php'; } ?> </aside> <aside class="other"> <header> <h1>Related Links</h1> </header> <nav id="side-links"> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> </nav> </aside> </aside> widgets/login.php: <div class="widget"> <h1>Log In</h1> <div class="inner"> <form action="login.php" id="login" method="post"> <fieldset id="inputs"> <input autocomplete="on" autofocus id="username" name="user" placeholder="Username" required type="text"> <input autocomplete="on" id="pass" name="password" placeholder="Password" required type="password"> </fieldset> <fieldset id="actions"> <input id="submit" type="submit" value="Log In"> <a href="register.php">Register</a> <a href="">Forgot Password?</a> </fieldset> </form> </div> </div> widgets/loggedin.php: <div class="widget"> <h1>Hello, <?php echo $user_data['first']; ?>!</h1> <div class="inner"> <nav id="side-links"> <li><a href="logout.php">Log Out</a></li> <li><a href="changepassword.php">Change Password</a></li> </nav> </div> </div> login.php: <?php include 'core/init.php'; if (empty($_POST)=== false) { $username = $_POST['user']; $password = $_POST['password']; if (empty($username) === true || empty($password) === true) { $errors[] = 'You must enter username and password'; } else if (user_exists($username) === false) { $errors[] = 'Username not found'; } else if (user_active($username) === false) { $errors[] = 'You must activate your account before you may login'; } else { $login = login($username, $password); if ($login === false) { $errors[] = 'The username/password combination you have entered is incorrect'; } else { $_SESSION['user_id'] = $login; header('Location: index.php'); exit(); } } } else { $errors[] = 'No data received.'; } include 'includes/overall/header.php'; if (empty($errors) === false) { ?> <div id="container"> <?php include 'includes/aside.php'; ?> <section id="content"> <h1>We tried to log you in but ...</h1> <?php echo output_errors($errors); } ?> </section> <div style="clear:both"></div> </div> <?php include 'includes/overall/footer.php'; ?> This processes the widgets/login.php login form. logout.php: <?php session_start(); unset($_SESSION['user_id']); session_destroy(); header('Location: index.php'); ?> One of the main things that I liked about this video tutorial is the fact that everything that makes the site work is in an included file instead of in the file itself. This is a benefit since the site is being turned over to people with not web development training. The pages themselves are designed so that all they will have to do is type in there information and post the site. I didn't realize when taking on this project that I would run into quite so much trouble with it. Having never worked with or even looked at PHP until this project, I almost feel like I'm in over my head but I pick up on the concepts faster than anyone else who has access to this project so it fell into my lap.
  11. At least here I can see where I might have an issue however I still don't know what to do to fix it. I noticed in users.php that all of the functions are green except for function logged_in(). That, to me, says that there must be something wrong with the function above it. Do you see any errors in that function?
  12. I removed the connect.php file (or at least I think I did) and attached the .zip file containing all the files in use. I then saw that my file was too big to upload (3.04MB). In using the development tools I was at least able to see that the session isn't traveling across pages. I can delete the cookie on all pages, log in on one and still have a log in form on the other. There is a block of code similar to what you mentioned in your last post that looks like this: if (logged_in() === true) { $session_user_id = $_SESSION{'id'}; $user_data = user_data($session_user_id, 'id', 'username', 'password', 'first', 'last', 'email'); if (user_active($user_data['username']) === false) { session_destroy(); header('Location: index.php'); exit(); } } After doing another test of it, when I log in on one page and go to another and refresh that page, it reflects me being logged in. When I log out, however, it redirects my to index.php like it should but it keeps me logged in. Here are the files: init.php : <?php session_start(); //error_reporting(0); require 'database/connect.php'; require 'functions/general.php'; require 'functions/users.php'; if (logged_in() === true) { $session_user_id = $_SESSION{'id'}; $user_data = user_data($session_user_id, 'id', 'username', 'password', 'first', 'last', 'email'); if (user_active($user_data['username']) === false) { session_destroy(); header('Location: index.php'); exit(); } } $errors = array(); ?> general.php: <?php function sanitize($data) { return mysql_real_escape_string($data); } function output_errors($errors) { $output = array(); foreach($errors as $error) { $output[] = '<li>' . $error . '</li>'; } return '<ul>' . implode('', $output) . '</ul>'; } ?> users.php: <?php function user_data($user_id) { $data = array(); $user_id = (int)$user_id; $func_num_args = func_num_args(); $func_get_args = func_get_args(); if ($func_num_args > 1) { unset($func_get_args[0]); $fields = '`' . implode('`, `', $func_get_args) . '`'; $data = mysql_fetch_assoc(mysql_query("SELECT $fields FROM `user` WHERE `id` = '$user_id'")); return $data; } } function logged_in() { return (isset($_SESSION['id'])) ? true : false; } function user_exists($username) { $username = sanitize($username); return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user` WHERE `username` = '$username'"), 0) == 1) ? true : false; } function user_active($username) { $username = sanitize($username); return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user` WHERE `username` = '$username' AND `active` = 1"), 0) == 1) ? true : false; } function user_id_from_username($username) { $username = sanitize($username); return mysql_result(mysql_query("SELECT `id` FROM `user` WHERE `username` = '$username'"), 0, 'id'); } function login($username, $password) { $user_id = user_id_from_username($username); $username = sanitize($username); $password = md5($password); return (mysql_result(mysql_query("SELECT COUNT(`id`) FROM `user` WHERE `username` = '$username' AND `password` = '$password'"), 0) == 1) ? $user_id : false; } ?> aside.php: <aside id="sidebar"> <aside class="widgets"> <?php if (logged_in() === true) { include 'includes/widgets/loggedin.php'; } else { include 'includes/widgets/login.php'; } ?> </aside> <aside class="other"> <header> <h1>Related Links</h1> </header> <nav id="side-links"> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> <li><a href="#">Sample Link</a></li> </nav> </aside> </aside> loggedin.php: <div class="widget"> <h1>Hello, <?php echo $user_data['first']; ?>!</h1> <div class="inner"> <nav id="side-links"> <li><a href="logout.php">Log Out</a></li> <li><a href="changepassword.php">Change Password</a></li> </nav> </div> </div> login.php: <div class="widget"> <h1>Log In</h1> <div class="inner"> <form action="login.php" id="login" method="post"> <fieldset id="inputs"> <input autocomplete="on" autofocus id="username" name="user" placeholder="Username" required type="text"> <input autocomplete="on" id="pass" name="password" placeholder="Password" required type="password"> </fieldset> <fieldset id="actions"> <input id="submit" type="submit" value="Log In"> <a href="register.php">Register</a> <a href="">Forgot Password?</a> </fieldset> </form> </div> </div> logout.php: <?php session_start(); unset($_SESSION['id']); session_destroy(); header('Location: index.php'); ?> I think that's all the files relating to this issue. It's driving me nuts that I've spent the entire day working on logging a user out. I thought sure this would be a quick fix.
  13. I'm taking that out but first I wanted to see what shows up in the developer tools (F12 in my browser). session.cookie_domain is not set
  14. I hadn't but it was because I was trying to see if the if statement was even executing. Neither die() statement executed so I changed the code to this: <?php session_start(); unset($_SESSION['id']); $_SESSION['id'] = 0; session_destroy(); header('Location: index.php'); ?> It worked once but once I logged in again to verify that it really did do the trick, I was unsuccessful in logging out again.
  15. So the session.cookie_path is set to "/"
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.