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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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