Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /******************************************************
- JotForm to MySQL Database Through Webhook
- Sample Script By Elton Cris - JotForm Tech Support
- Tested on form https://form.jotform.com/62893435003959
- You can submit this form and check results on http://eltoncris.xyz/view.php
- ******************************************************/
- //Replace with your DB Details
- $servername = "localhost";
- $username = "id3298741_xdacork";
- $password = "SKATER13141516";
- $dbname = "id3298741_hots";
- $dbtable = "jugadores";
- //Create connection
- $mysqli = new mysqli($servername, $username, $password, $dbname);
- //Check connection
- if ($mysqli->connect_error) {
- die("Connection failed: " . $mysqli->connect_error);
- }
- //Get field values from the form
- //Get unique submissionID - nothing to change here
- $sid = $mysqli->real_escape_string($_REQUEST['submissionID']);
- //Get form field values and decode - nothing to change here
- $fieldvalues = $_REQUEST['rawRequest'];
- $obj = json_decode($fieldvalues, true);
- //Replace the field names from your form here
- $fname = $mysqli->real_escape_string($obj['q15_yourName'][first]);
- $lname = $mysqli->real_escape_string($obj['q15_yourName'][last]);
- $email = $mysqli->real_escape_string($obj['q11_valuador']);
- $message = $mysqli->real_escape_string($obj['q10_telefono']);
- $result = $mysqli->query("SELECT * FROM $dbtable WHERE Id_no = '$sid'");
- //If submission ID exist, update record
- if ($result->num_rows > 0) {
- $result = $mysqli->query("UPDATE $dbtable SET Name = '$fname', apellido = '$lname', Rtg_Nat = '$email', telefono = '$message' WHERE Id_no = '$sid'");
- echo "Existing Record Updated!";
- }
- //If new submission, insert record
- else{
- $result = $mysqli->query("INSERT IGNORE INTO $dbtable (sid, Name, apellido, Rtg_Nat, telefono) VALUES ('$sid', '$fname', '$lname','$email','$message')");
- echo "New Record Added!";
- if ($result === false) {echo "SQL error:".$mysqli->error;}
- }
- $mysqli->close();
- ?>
Add Comment
Please, Sign In to add comment