Jump to content

ragos200

New Members
  • Posts

    1
  • Joined

  • Last visited

ragos200's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. HI guys, Created a matchmaking form with 2 users,user 1 fills it out saves the information then user 2 fills it out and the result is calculated. Problem is that user 1 fills it out and it won't recognize user 2 so I can't calculate anything. I have tried many times to fix this but it dosn't work, Please help me by telling me what's wrong with my code. <?php session_start(); $difference=0; $match=0; $nmatch=1; $result=1; if(isset($_POST['check'])) { if (!isset($_SESSION['userOneName'])) { $_SESSION['userOneName'] = $_POST["username"]; $_SESSION['userOneBirthYear'] = $_POST["birthyear"]; $_SESSION['userOneGoal'] = $_POST["goal"]; $_SESSION['userOneFavorite'] = $_POST["favorite"]; $_SESSION['userOneCat'] = $_POST["cat"]; $_SESSION['userOneDog'] = $_POST["dog"]; $_SESSION['userOneHamster'] = $_POST["hamster"]; $_SESSION['userOneGoldfish'] = $_POST["goldfish"]; $_SESSION['userOneHuman'] = $_POST["human"]; // create ALL session variables for user1 according to what's in the input vars: $_SESSION["userOneSomething"]=$_POST["something"]; } else { $_SESSION['userTwoName'] = $_POST["username"]; $_SESSION['userTwoBirthYear'] = $_POST["birthyear"]; $_SESSION['userTwoGoal'] = $_POST["goal"]; $_SESSION['userTwoFavorite'] = $_POST["favorite"]; $_SESSION['userTwoCat'] = $_POST["cat"]; $_SESSION['userTwoDog'] = $_POST["dog"]; $_SESSION['userTwoHamster'] = $_POST["hamster"]; $_SESSION['userTwoGoldfish'] = $_POST["goldfish"]; $_SESSION['userTwoHuman'] = $_POST["human"]; } // Now we're in user 2. Create ALL session vars for user 2- AND Calculate Match if(isset($_SESSION["goal"])) if ($_SESSION['goal'] !== 'romance') { session_unset (); echo "sorry,no match"; } #calculate first result { $difference +=abs('$userOneBirthYear'-'$userTwoBirthYear'); } if ($_SESSION['userOneFavorite'] == 'userTwoFavorite') { $result +=$nmatch +10; } { $_SESSION["check"]= $_POST["check"]; $_SESSION["username"]= $_POST["username"]; $_SESSION["birthyear"]= $_POST["birthyear"]; $_SESSION["goal"]= $_POST["goal"]; $_SESSION["favorite"]= $_POST["favorite"]; } if(isset($_POST['cat'])) { $_SESSION["cat"]= $_POST["cat"]; } if(isset($_POST['dog'])) { $_SESSION["dog"]= $_POST["dog"]; } if(isset($_POST['hamster'])) { $_SESSION["hamster"]= $_POST["hamster"]; } if(isset($_POST['goldfish'])) { $_SESSION["goldfish"]= $_POST["goldfish"]; } if(isset($_POST['human'])) { $_SESSION["human"]= $_POST["human"]; } if(isset($_SESSION["dog"])) if ($_SESSION['userOneDog'] == 'userTwoDog') { $nmatch +=8+$match; } else if(isset($_SESSION["dog"])) if ($_SESSION['userOneDog'] !== 'userTwoDog') { $nmatch +=8+$match; } if(isset($_SESSION["cat"])) if ($_SESSION['userOneCat'] == 'userTwoCat') { $nmatch +=8+$match; } else if(isset($_SESSION["cat"])) if ($_SESSION['userOneCat'] == 'userTwoCat') { $nmatch +=8+$match; } if(isset($_SESSION["hamster"])) if ($_SESSION['userOneHamster'] == 'userTwoHamster') { $nmatch +=8+$match; } else if(isset($_SESSION["hamster"])) if ($_SESSION['userOneHamster'] == 'userTwoHamster') { $nmatch +=8+$match; } if(isset($_SESSION["goldfish"])) if ($_SESSION['userOneGoldfish']=='userTwoGoldfish') { $nmatch +=8+$match; } else if(isset($_SESSION["goldfish"])) if ($_SESSION['userOneGoldfish'] !== 'userTwoGoldfish') { $nmatch +=8+$match; } if(isset($_SESSION["human"])) if ($_SESSION['userOneHuman'] == 'userTwoHuman') { $nmatch +=8+$match; } else if(isset($_SESSION["human"])) if ($_SESSION['userOneHuman'] !== 'userTwoHuman') { $nmatch +=8+$match; } #final result if(isset($_SESSION['userTwoFavorite'])) echo "system calculated the result"; echo " your compatabilaty grade " .$result; if(isset($_SESSION['check'])) if ($result <= 50) { session_unset ();echo " keep away"; } if ($result <= 50-70) { session_unset (); echo "not great"; } else if ($result >= 75) { session_unset (); echo " you are a match made in heaven "; } //need to think where this goes:into what condition session_unset (); echo " ?another round"; } ?> Here is the form in html code: <!doctype html> <html> <head> <title>matchmaker</title> <meta charset="UTF-8"> <meta name="viewport" content="initial-scale=1.0"> <style> body{text-align: center; border-style: solid; padding:50px;} </style> </head> <body> <h1>MatchMaker-2017-Find Your Soulmate</h1> <h2>user 1</h2> <form method="post"> <br> <hr> <label>?Name?</label> <input type="text" name="username"> <br> <hr> <label>Birthyear: </label> <input type="text" name="birthyear"> <br> <br> <hr> <label>looking for soul mate</label><br> <input type="radio" name="goal" value="romance">romantic reasons <input type="radio" name="goal" value="friendship">friendship reasons <input type="radio" name="goal" value="luck">potluck<br> <hr> <label>Animals I love:</label> <br> <input type="checkbox" name="cat" value="cat">cats<br> <input type="checkbox" name="dog" value="dog">dogs<br> <input type="checkbox" name="hamster" value="hamster">hamsters <br> <input type="checkbox" name="goldfish" value="goldfish">goldfish <br> <input type="checkbox" name="human" value="human">humans <br> <hr> <label>favourite thing:</label> <input type="text" name="favorite"> <br> <br> <button type="sumbit" name="check" value="check">check compatibility</button> </form> </body> </html> Thank You
×
×
  • 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.