Jump to content

knoxinator

New Members
  • Posts

    5
  • Joined

  • Last visited

knoxinator's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. hello I can't seem to figure out my error <?php if(empty($_POST) === false) { session_start(); function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } $errors = []; if(isset($_POST['name'], $_POST['phone'], $_POST['date'], $_POST['type'], $_POST['message'])) { $fields = [ 'name' => $_POST['name'], 'phone' => $_POST['phone'], 'date' => $_POST['date'], 'type' => $_POST['type'], 'message' => $_POST['message'] ]; foreach ($fields as $field => $data) { if(empty($data)) { $errors[] = "The " . $field . " is required"; } } if(empty($errors) === true) { $name = test_input($_POST['name']); $phone = test_input($_POST['phone']); $date = test_input($_POST['date']); $type = test_input($_POST['type']); $message = test_input($_POST['message']); $to = "knoxinator2@gmail.com"; $subject = "Hello I am " . $name; echo $body = " <html> <head> <title>Contact Form</title> <style> body { background-color: #EEEEEE; } .main { width: 960px; margin: 0 auto; background-color: white; padding: 100px; } .main h3 { color: green; margin-bottom: 30px; } table, tr, th, td { border: 1px solid lightGray; border-collapse: collapse; font-size: 20px; } th, td { padding: 5px; text-align: justify; line-height: 30px; } .footer { line-height: 5px; margin-top: 50px; color: green; } </style> </head> <body> <div class='main'> <h3>Hello,<br>I am $name, my information is bellow_</h3> <table> <tr> <th>Name</th> <td>$name</td> </tr> <tr> <th>Phone</th> <td>$phone</td> </tr> <tr> <th>Date</th> <td>$date</td> </tr> <tr> <th>Moving Type</th> <td>$type</td> </tr> <tr> <th>Message</th> <td>$message</td> </tr> </table> <div class='footer'> <h3>Thank you.</h3> <h3>$name</h3> </div> </div> </body> </html> "; // Always set content-type when sending HTML email $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=UTF-8" . "\r\n"; // More headers $headers .= 'From: <' . $name . '>' . "\r\n"; //$headers .= 'Cc: myboss@example.com' . "\r\n"; mail($to,$subject,$body,$headers); $_SESSION['success'] = "Success"; header('location: index.php'); exit(); } elseif(empty($errors) === false) { echo "Wrong"; $_SESSION['fields'] = $fields; $_SESSION['errors'] = $errors; header('location: index.php'); exit(); } } } else { header('location: index.php'); exit(); } the error I am getting is Parse error: syntax error, unexpected '[' in G:\PleskVhosts\footydoubles.info\T20Empire.com\sendmail.php on line 13
  2. Greetings, I have this website http://www.heresourwedding.com It is a poker league website just sitting on a spare domain at the moment. Anyway each day after a poker league game is played I will add scores into the leaderboards. For example if the game was played at Durack Tavern I would put the name and score in the Durack Tavern page and then the overall page and then the player of the week page. What I am trying to figure out is how to put the scores in just the Durack Tavern page and the website automatically puts the information into the other 2 pages. If you want to have a look go to leaderboard/Durack tavern, then click on the red spade at bottom of page. Username is: user5 Password is : password Here is the code for durplayers.php <?php session_start(); if(!isset($_SESSION["sess_user"])){ header("location:index.php"); } include "dbconnect.php"; if(isset($_POST["submit"])) { if(!empty($_POST['username']) && !empty($_POST['points'])) { $user = $_POST['username']; $points = $_POST['points']; $sql = "SELECT username,points FROM durack WHERE username='".$user."'"; $result = mysqli_query($conn, $sql); $numrows = mysqli_num_rows($result); //update the points if($numrows!=0) { while($row=mysqli_fetch_assoc($result)) { $username=$row['username']; $oldpoints=$row['points']; } $totalPoints = $oldpoints + $points; $sql1 = "UPDATE durack SET points='".$totalPoints."' WHERE username='".$user."'"; if(mysqli_query($conn, $sql1)) { header("Location: AddDurack.php?added=Points"); } } // Add player and Points else { $sql2 = "INSERT INTO durack(`username`,`points`) values ('$user',$points)"; if(mysqli_query($conn, $sql2)) { header("Location: AddDurack.php?added=PlayerAndPoints"); } } } else { header("Location: AddDurack.php?added=mandatory"); } mysqli_close($conn); } ?> The Durack Tavern table is called Durack, the player of the week table is called potw and the overall table is called players if that helps. I tried duplicating the INSERT command for potw and players but I just got errors. Cheers.
  3. I need help on the code for adding int values to a database. I am keeping scores each week for a poker club and each week I need to add the scores into the database so that it shows the total on the webpage. The page would look like this Name: Score: and the total scores page would be a table with the name on the left and total score on the right. It is very important that I can add scores each week that add on top of the total score for that player. Cheers Also the tables have already been created on mySQL
×
×
  • 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.