Jump to content

[SOLVED] storeing data


paulman888888

Recommended Posts

Assuming that $_GET['name'] contains a short string and $_GET['score'] a number. You would probably wont VARCHAR(80) and INT respectively.

 

Then, you code might look something like...

 

<?php

  if (isset($_GET['name']) && isset($_GET['score'])) {
    // here you will need to connect to the database.

    $name = $_GET['name'];
    $score = $_GET['score'];

    $sql = "INSERT INTO tbl (name,score) VALUES ('$name','$score');";

    if (mysql_query($sql) && mysql_affected_rows()) {
      echo "Record added";
    } else {
      echo "There was a problkem adding your score";
      // do some additional debugging.
    }

  }

?>

 

If this makes no snese to you Id suggest you start reading that php book in my signiture.

Link to comment
https://forums.phpfreaks.com/topic/107765-solved-storeing-data/#findComment-552417
Share on other sites

As an addition to what thorpe said you could use some security to prevent injection:

$name = $_GET['name']; should be $name=mysql_real_escape_string($_GET['name']);

 

and so on. If you have a form that accept input you should use htmlspecialchars in order to prevent XSS.

Good luck.

Link to comment
https://forums.phpfreaks.com/topic/107765-solved-storeing-data/#findComment-552428
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.