I have a problem regarding to the condition.
if the user is not logged in, shoe the log in form only 3 guestbook comments will show the guestbook form will not be available if the user is not logged in, show the logout button show all guestbook comments the log in form will not be available help me or try to give other answershere is the code
- <html>
- <head>
- <style>
- .error {color: #FF0000;}
- </style>
- </head>
- <body>
- <?php
- echo " failed" . mysqli_conect_error();
- }else{
- echo "connect";
- }
- $nameErr = $ageErr = $emailErr = "";
- $name = $age = $email = $comment = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST")
- {
- {
- $nameErr = "Name is required";
- }
- else
- {
- $name = test_input($_POST["name"]);
- {
- $nameErr = "Only letters and white space allowed";
- }
- }
- {
- $emailErr = "Email is required";
- }
- else
- {
- $email = test_input($_POST["email"]);
- {
- $emailErr = "Invalid email format";
- }
- }
- {
- $comment = "";
- }
- else
- {
- $comment = test_input($_POST["comment"]);
- }
- $age = "";
- }
- else
- {
- $age = test_input($_POST["age"]);
- }
- }
- function test_input($data)
- {
- return $data;
- }
- ?>
- <p><span class="error">* required field.</span></p>
- Name: <input type="text" name="name" value="<?php echo $name;?>">
- <span class="error">* <?php echo $nameErr;?></span>
- <br><br>
- Age: <input type="text" name="age" value="<?php echo $age;?>">
- <span class="error">*<?php echo $ageErr;?></span>
- <br><br>
- E-mail: <input type="text" name="email" value="<?php echo $email;?>">
- <span class="error">* <?php echo $emailErr;?></span>
- <br><br>
- Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>
- <br><br>
- <input type="submit" name="submit" value="Send Comment">
- </form>
- <?php
- echo "<h2>Your Input:</h2>";
- echo $name;
- echo "<br>";
- echo $age;
- echo "<br>";
- echo $email;
- echo "<br>";
- echo $comment;
- echo "<br>";
- ?>
- </body>
- </html>