Page 4 of 6 FirstFirst 123456 LastLast
Results 49 to 64 of 81

Thread: Review system

  1. #49
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s
    Yeah goot point Jamie, of you need to return a form variable you would need $_GET or $_REQUEST and if you are evaluating the submit option (which would take the form action of POST) then you could use $_POST

  2. Received thanks from:

    nvening (02-08-2007)

  3. #50
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    yep, it displayed that so it must be being submitted properly?

    EDIT:

    This is what i have atm:

    PHP Code:
    <?php
    //Include a file include.php which is above the current directory (so can't be accessed directly from a browser = more security)
    require_once('include.php');

    if(isset(
    $_REQUEST['posted'])) {
        echo 
    'this is displayed because the form has been submitted';  
        
    //Put ID in URL into $id variable
        
    $id $_REQUEST['id'];
        
        
    $name_rev=$_POST['name'];
        
    $email_rev=$_POST['email'];
        
    $rating_rev=$_POST['rating'];
        
    $review_rev=$_POST['review'];
        
        
    //Check if the form was filled out correctly...if not print an error and change $error variable to true
        
    $error false;
        if (empty(
    $name_rev)){echo 'You forgot to enter your name'$error true;}
        if (empty(
    $email_rev)){echo 'You forgot to enter your email'$error true;}//remove this line if the email isn't necessary
        
    if (empty($review_rev)){echo 'You forgot to write a review'$error true;}
        
        
    //Only continue if the form was filled out correctly
        
    if ($error false){
        
        
    //Do some basic handling of submitted stuff:
        //Make sure the rating is a number
        
    $rating_rev=doubleval($rating_rev);
        
    //Add slashes to the text to prevent problems occuring [remember to use stripslashes(...) when printing the review]
        
    $email_rev=addslashes(email_rev);
        
    $review_rev=addslashes(review_rev);
        
    $name_rev=addslashes(name_rev);
        
        
    //Open database connection by calling function in include.php
        
    $dbh=db_connect();
        
    $sql "INSERT INTO restreview VALUES 
            ('
    $id','$name_rev','$email_rev','$rating_rev','$review_rev')";      
            print(
    $sql);

            
    mysql_query($sql) or die ('I cannot update the database because: ' mysql_error()); 
            
               
    mysql_close();    
        }
    //end if ($error = false){...


    ?> 
    <h1>Your Details:</h1>

    <form action="resturant.php?id=<? echo $id?>" method="post">
    <span class="det">Name:</span> <input style="margin-left: 5px;" type="text" name="name"><br/>
    <span class="det">Email:</span> <input style="margin-left: 7px;" type="text" name="email"> <span class="det">(will not be displayed)</span><br/>

    <span class="det">Rating:</span> <select name="rating">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3" selected="selected">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    </select>
    <br/>
    <h1>Review:</h1>
    <textarea rows="5" cols="50" name="review">
    Enter your review here
    </textarea>
    <input type="hidden" name="validation" value="1"/>
    <p style="margin-left: 50px;" >
    <input type="submit" name="posted" value="Submit" >
    <input type="reset" value="Reset">
    </p>
    </form>
    no errors but nothing is added to the database
    Last edited by nvening; 02-08-2007 at 05:58 PM.
    (\__/)
    (='.'=)
    (")_(")

  4. #51
    Member
    Join Date
    Nov 2006
    Posts
    103
    Thanks
    10
    Thanked
    6 times in 6 posts
    • jamiesalter's system
      • Motherboard:
      • Abit IP35 Pro
      • CPU:
      • Intel Q6600 (w/ Scythe ninja @ 3Ghz)
      • Memory:
      • 4 x 1Gb Corsair PC2-6400
      • Storage:
      • 1 x WD 500GB AAKS
      • Graphics card(s):
      • XFX 8800GTS (w/ Thermalright HR-03 PLUS)
      • PSU:
      • Corsair 620Watts
      • Case:
      • CM690
      • Monitor(s):
      • HannsG 216D (21.6")
    Ahhh, I've spotted a problem:
    Change
    PHP Code:
    if ($error false){ 
    to
    PHP Code:
    if ($error == false){ 

  5. Received thanks from:

    nvening (02-08-2007)

  6. #52
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    ah, top man, now we have "INSERT INTO restreview VALUES ('1','name_rev','email_rev','3','review_rev')I cannot update the database because: Column count doesn't match value count at row 1" XD - hmmmmmm
    (\__/)
    (='.'=)
    (")_(")

  7. #53
    Member
    Join Date
    Nov 2006
    Posts
    103
    Thanks
    10
    Thanked
    6 times in 6 posts
    • jamiesalter's system
      • Motherboard:
      • Abit IP35 Pro
      • CPU:
      • Intel Q6600 (w/ Scythe ninja @ 3Ghz)
      • Memory:
      • 4 x 1Gb Corsair PC2-6400
      • Storage:
      • 1 x WD 500GB AAKS
      • Graphics card(s):
      • XFX 8800GTS (w/ Thermalright HR-03 PLUS)
      • PSU:
      • Corsair 620Watts
      • Case:
      • CM690
      • Monitor(s):
      • HannsG 216D (21.6")
    Try changing it to read this assuming that the columns in your mysql database are named id, name, email, rating and review.
    PHP Code:
    INSERT INTO restreview (idnameemailratingreviewVALUES ('$id','$name_rev','$email_rev','$rating_rev','$review_rev'); 

  8. Received thanks from:

    nvening (02-08-2007)

  9. #54
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    Great, after some tweaking and some extra code ive got it working!

    heres the code:

    PHP Code:
    <?php
    //Include a file include.php which is above the current directory (so can't be accessed directly from a browser = more security)
    require_once('include.php');

    if(isset(
    $_REQUEST['posted'])) {
         
        
    //Put ID in URL into $id variable
        
    $id $_REQUEST['id'];
        
        
    $name_rev=$_POST['name'];
        
    $email_rev=$_POST['email'];
        
    $rating_rev=$_POST['rating'];
        
    $review_rev=$_POST['review'];
        
        
    //Check if the form was filled out correctly...if not print an error and change $error variable to true
        
    $error false;
        if (empty(
    $name_rev)){echo '<h2 style="color: red; ">ERROR: You forgot to enter your name</h2>'$error true;}
        if (empty(
    $email_rev)){echo '<h2 style="color: red; ">ERROR: You forgot to enter your email</h2>'$error true;}//remove this line if the email isn't necessary
        
    if (empty($review_rev)){echo '<h2 style="color: red; ">ERROR: You have not entered your review!</h2>'$error true;}
        if (!
    $email_rev == "" && (!strstr($email_rev,"@") || !strstr($email_rev,"."))){echo '<h2 style="color: red; ">ERROR: Your email address is not valid</h2>'$error true;}
        
        
    //Only continue if the form was filled out correctly
        
    if ($error == false){
        
        
    //Do some basic handling of submitted stuff:
        //Make sure the rating is a number
        
    $rating_rev=doubleval($rating_rev);
        
    //Add slashes to the text to prevent problems occuring [remember to use stripslashes(...) when printing the review]
        
    $email_rev=addslashes($email_rev);
        
    $review_rev=addslashes($review_rev);
        
    $name_rev=addslashes($name_rev);
        
        
    //Open database connection by calling function in include.php
        
    $dbh=db_connect();
        
    $sql "INSERT INTO restreview (id, name, email, rating, review) VALUES ('$id','$name_rev','$email_rev','$rating_rev','$review_rev')";

            
    mysql_query($sql) or die ('I cannot update the database because: ' mysql_error()); 
            
        
    $conf '<h2>Thank you, your review has been submitted and will be displayed shortly</h2>';
            
               
    mysql_close();    
        }
    //end if ($error = false){...


    ?> 
    <h1>Your Details:</h1>

    <form action="resturant.php?id=<? echo $id?>" method="post">
    <span class="det">Name:</span> <input style="margin-left: 5px;" type="text" name="name"><br/>
    <span class="det">Email:</span> <input style="margin-left: 7px;" type="text" name="email"> <span class="det">(will not be displayed)</span><br/>

    <span class="det">Rating:</span> <select name="rating">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3" selected="selected">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    </select>
    <br/>
    <h1>Review:</h1>
    <textarea rows="5" cols="50" name="review">
    Enter your review here
    </textarea>
    <input type="hidden" name="validation" value="1"/>
    <p style="margin-left: 50px;" >
    <h1>Please ensure your detials are corrent and check through your review before submission</h1>
    <input type="submit" name="posted" value="Submit" >
    <input type="reset" value="Reset">
    </p>
    </form>

    <? echo $conf?>
    thanks for the help guys!!
    (\__/)
    (='.'=)
    (")_(")

  10. #55
    Late Night Ninja! CrazyMonkey's Avatar
    Join Date
    Oct 2006
    Location
    Bristol
    Posts
    1,510
    Thanks
    29
    Thanked
    44 times in 43 posts
    • CrazyMonkey's system
      • Motherboard:
      • Asus M4N98TD Evo
      • CPU:
      • Phenom II X6 1055T @ 4.1ghz
      • Memory:
      • 8GB DDR3 Dominator @ 1700mhz
      • Storage:
      • 120GB OCZ Vertex 2E - 1TB Hitatchi
      • Graphics card(s):
      • 2x 460 1GB
      • PSU:
      • 850W
      • Case:
      • Silverstone Fortress FT02R-WRI Ltd.Edition
      • Operating System:
      • Win 7, XP, Server2008 RC1, Gentoo
      • Monitor(s):
      • 24" Acer LED - 22" Belinea - 19" Samsung - 19" IIyama
      • Internet:
      • 50 MB Virgin Media Cable
    Good job people

  11. #56
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    Ok, the database remembers line breaks however how do i get them to be displayed on the website??

    Thanks
    (\__/)
    (='.'=)
    (")_(")

  12. #57
    Member
    Join Date
    Nov 2006
    Posts
    103
    Thanks
    10
    Thanked
    6 times in 6 posts
    • jamiesalter's system
      • Motherboard:
      • Abit IP35 Pro
      • CPU:
      • Intel Q6600 (w/ Scythe ninja @ 3Ghz)
      • Memory:
      • 4 x 1Gb Corsair PC2-6400
      • Storage:
      • 1 x WD 500GB AAKS
      • Graphics card(s):
      • XFX 8800GTS (w/ Thermalright HR-03 PLUS)
      • PSU:
      • Corsair 620Watts
      • Case:
      • CM690
      • Monitor(s):
      • HannsG 216D (21.6")
    $output_string = nl2br($output_string);

    The above function nl2br() will convert the line breaks to <br> html tags.

  13. #58
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    aha, well, thats absolutely fantastic, i think ive finished the system!!

    Thanks so much to everyone who has helped once again.

    Now, tomorrow, search XD

    Hopefully i should be able to find some code to adapt though as i imagine its a pretty common use!!

    (\__/)
    (='.'=)
    (")_(")

  14. #59
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    Ok, so far the search script is working well, however there are a couple of things which i would like to add on which im not sure how to do.

    1) two checkboxes which will narrow the results down by whether they are ticked or not, producing a yes if ticked which will only select the rows which have a yes for the option. ie Takeaway *checkbox* - if ticked it will give it a yes value and so only the resturants which offer takeaway will be displayed.

    2) how to modify it so when you press search you are taken to another page where the results are displayed, so that i can include the search box in other areas of the site.
    Last edited by nvening; 02-05-2011 at 01:52 PM.
    (\__/)
    (='.'=)
    (")_(")

  15. #60
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s
    To submit to a different page you will need to change your 'action' command within the form concerned to the page you wish to send the user to.

    e.g:

    <form name="search" method="post" action="index.php?page=search_results">

    (this assumes you are taking a variable called 'page' from the query string to determine which page to display (ask for details))

    The page you send the user to will have to call in the posted variables using $_GET or $_REQUEST as you would do if the script posted to the same page.

    The other piece is more complex...It's a friday afternoon....

  16. #61
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    details?

    lol

    and dw about the other thing, i can carry on and add it later
    (\__/)
    (='.'=)
    (")_(")

  17. #62
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s
    What do you mean by details?!

    in the short term, you can just use something like action="search_results.php"

    Assuming the page you want to send people to is called search_results.php

    The logic behind using a variable to decide which page to display is as follows:

    include (literally include!) a file into your index file called something like 'page_selection.php'

    In this page, put a switch statement, which evaluates a variable (usually) passed in the query string in the format index.php?page=news or something like that.

    You switch would then use $_REQUEST[page] and based on the value, include a different page (if that makes sense)

    This way you can have a template, and just use the page_selection.php include to decide which content to display in the middle.

  18. #63
    lazy student nvening's Avatar
    Join Date
    Jan 2005
    Location
    London
    Posts
    4,656
    Thanks
    196
    Thanked
    31 times in 30 posts
    Well actually if ive understood properly ive already done the inverse of that as i have the template split into top and bottom files which i then just include at the top and bottom of each page - im sure your way is better but if it aint fixed...
    (\__/)
    (='.'=)
    (")_(")

  19. #64
    www.dougmcdonald.co.uk
    Join Date
    May 2007
    Location
    Bath
    Posts
    523
    Thanks
    5
    Thanked
    20 times in 20 posts
    • DougMcDonald's system
      • Motherboard:
      • Asus P5B Deluxe
      • CPU:
      • Inter Core 2 Duo E6600
      • Memory:
      • 2 x 2GB - Geil Black Dragon PC6400
      • Storage:
      • 2 x 400GB Samsung Spinpoints (Running in Matrix array) 100GB @ RAID0 + 300GB @ RAID1
      • Graphics card(s):
      • BFG nVidia 8800GTS 320MB OC2
      • PSU:
      • Corsair HX520W modular
      • Case:
      • Lian-Li PC7 II Plus
      • Monitor(s):
      • LG 17" Flat Thingy
      • Internet:
      • Crappy BT 1MB Unreliable wank :s
    The method I'm suggesting can be used to complement your header and footer files.

    What is enables you to do, is have a single index.php and have all the content displayed through that. It enables you to only require one template page.

    Traditional web design has historically has seperate pages eg. news.html, products.html etc

    This method is often transposed on to scripting languages e.g. home.php, contactus.php etc

    What you can do, is simply have one master page, e.g. index.php and then have the links to other pages in the format index.php?page=home, index.php?page=news etc etc

    Inside index.php, you can put a little logic, so it knows which page to include when the page variable is set, and voila a single page with all other content plugged into the middle.

    Example:

    index.php
    PHP Code:
    <?php    session_start();?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html>
        <head>    
        </head>
        <?php
                   
    //by using one index.php file you can call your main script library at the start, and 
                   //setup a DB connection only once
            
    require_once("scripts/library.php");
            
    connectToDB();
        
    ?>
        <body>
            <div id="header"></div>
            <div id="content">
                <div id="innercontent">    
                                    //here you include your navcontroller file which dictates what content is 
                                    //included in the page
                    <?php include("includes/navcontroller.php");?>
                </div>
            </div>
            <div id="footer">
            </div>
        </body>
    </html>
    navcontroller.php

    PHP Code:
    <?
        
    if(isset($file))
        {
            switch (
    $file)
            {
                case 
    "home":
                    include 
    "includes/home.php";
                    break;
                case 
    "portfolio":
                    include 
    "includes/portfolio.php";
                    break;
                            
    //the default situation in a switch catches the situation where the file variable 
                            //has been set to something stupid, like file=jhasdkjf
                
    default:
                    print(
    "<h1>site error</h1>");
                    print(
    "<hr/>");
                    print(
    "<h2>No Page Found</h2>");
                    print(
    "<p class=\"content\">
                        The link you have chosen has not found a valid page use the link below to
                        return to the home page</p><p class=\"content\">
                        Please check the link if you typed it yourself, use the <a href=\"index.php?file=contact\">
                        contact</a> form to inform the webmaster of a site error.</p>"
    );
                    print(
    "<hr/>");
            }    
        }
            
    // This catches the default situation where no 'file' variable has been set
        
    else
        {
            include 
    "includes/home.php";
        }
    ?>
    In this example you would need files inside the 'includes' directory which would contain you content. home.php and portfolio.php in this example.

    I hope that clarifies things

Page 4 of 6 FirstFirst 123456 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 24-11-2006, 07:40 PM
  2. Mesh Again!!
    By atomicjeep in forum Pre-Built Laptops and Desktops
    Replies: 34
    Last Post: 03-04-2006, 07:54 PM
  3. Abit NF7-S revision 2 information
    By Lee H in forum SCAN.care@HEXUS
    Replies: 22
    Last Post: 30-10-2004, 07:13 PM
  4. Newbie needing help with Barton XP2500+ system...
    By adlamb in forum PC Hardware and Components
    Replies: 17
    Last Post: 12-04-2004, 05:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •