Jump to content
Larry Ullman's Book Forums

margaux

Members
  • Posts

    453
  • Joined

  • Last visited

  • Days Won

    52

Posts posted by margaux

  1. Thanks Larry, any pointers re approach and database design would be great!

     

    I have 2 projects. I'd like to try doing this from scratch as I think it will be a good learning exercise.

     

    1. Display a calendar of availability for one property. Ideally a monthly calendar will be displayed with the background colour coded to indicate available, not available, pending. This image is the general idea, http://www.google.co...,r:13,s:0,i:113

     

    The rental fee will vary depending on time of year and length of booking. Booking period can be for any number of days, not just per week. Booking periods can begin and end on any day. The initial display will show the current month with a little arrow on the top right corner to link to the next calendar month which will then have forward and backward arrows. The visitor will be able to click the arrows to go back and forth through calendar months to check availability. Then a form will collect booking information from the user and check that the requested dates are indeed available and email the owner the request.

     

    2. Room booking system - multiple rooms for set periods during the day. Display similar to above but by week.

  2. You can have 2 forms on the same page but you must differentiate the processing in some way. For both the edit and the delete processing you check for $_SERVER['REQUEST_METHOD'] == POST. Really what you want to do is have 2 different checks - one for form 1 and one for form 2.

     

    The error 'undefined sure index' is because you check for it before it has been defined. Alter the code to

    if (isset($_POST['sure'])) {
    

    $_POST['sure'] will only be set if it has been checked so you can then delete that record.

     

    If you try to update a record without actually changing anything you won't get an error but mysqli_num_rows will return 0 rows because no rows have actually been updated.

     

    A couple of suggestions if you don't mind:

    1. You are missing a curly brace after the first if conditional.
    2. It's really helpful if you comment your big nested ifs to quickly see where each one ends.
    3. I would suggest that you structure this as one form - having 2 forms makes the logic more complicated than it needs to be.

  3. In newbookentry.php, you could try something like

    if (isset($_POST['member'])) {
     $members = implode(", ",$_POST['member']);
    }
    else {
     $members='Please select a member';
    }
    echo $members;
    

     

    If the data is going to be stored in a d/b, I like to give each checkbox a unique name e.g. member1, member2 etc. Then you can loop through them to identify each checkbox specifically.

  4. It's not clear what your problem is which you need to work out. What's not working? Are you getting error messages? Is your issue with sending emails from XAMPP or that you are not able to assign an email address to your variable $e? In my previous post, I suggested some code. What does 'not working' mean? When you run your script, what happens? It would help if you gave more information e.g. what does your database look like? Since we don't have the book, you have to provide this info.

  5. I can't tell if you got this to work or not. If so ignore the rest of the response.

     

    At some point in the user registration process you must have collected the user's email address? and created a record for the user which uniquely identifies him and stored his details in the d/b? For the user to change his password, he must input some details which you can use to access his info from the database including his email address. For example, if he is required to enter a password and username to change his password you can do something like

    $r = ($dbconn, "SELECT email FROM users WHERE username = $_POST['username'] AND password=SHA1($_POST['password']) LIMIT 1");
    if (mysqli_num_rows($r) == 1) {
    list($email) = $mysqli_fetch_array($r, MYSQLI_NUM)
    }
    

     

    Then you can use $email in your mail() function. Not sure if the above helps, but as I don't know the full code, its difficult to know what you have to work with. I skipped a few steps, particularly security ones, so if you have any questions on the above, feel free to comment.

  6. I get the following error when I run the sessions.php script which includes the session handler functions

    Warning: session_write_close() [function.session-write-close]: Failed to write session data (user). Please verify that the current setting of session.save_path is correct (/Applications/MAMP/tmp/php) in /Applications/MAMP/htdocs/advanced/sessions.php on line 37

    line 37 is the call to session_write_close();

     

    What does this mean exactly and how do I rectify it? Incidentally there is a session text file being saved in the tmp directory referred to - its full of data that I don't understand.

  7. @Benney,

    This forum is primarily for people learning/working in various programming languages for web development, PHP, MySQL, Javascript, Ajax and other technologies that Larry has authored books on. You can also ask general questions on these subjects. You may not find alot of threads on business ideas and problems although Larry does touch on some general concepts in his e-commerce book.

     

    If you are looking for information/discussion on programming languages and concepts regarding building web sites, you will find that Larry and many others here are very helpful and generous with their time and knowledge. Be sure to read the forum guidelines and remember that people are giving their time and knowledge freely. If someone has given you a lot of help, its nice to thank them. Happy learning :)

    • Upvote 1
  8. That's correct.

    function make_full_name($first, $last) {
    return $name=$first . ' ' . $last;
    }
    

     

    In your calling script, call the function with the 2 arguments and store the return value in a variable.

    $fullname  = make_full_name($fname, $lname);
    

     

    You can then use $fullname in the calling script to do whatever - echo to the browser, send as part of an email, insert to a database.

×
×
  • Create New...