Jump to content

pixy

Members
  • Posts

    295
  • Joined

  • Last visited

    Never

Posts posted by pixy

  1. 1. You will always want to escape $_GET variables so that people do not enter malicious content onto your site.
    2. Here's what I think you want:
    [code]
    <?php
    if (isset($_GET['name'])) {
      $name = $_GET['name'];
      $query = "SELECT * FROM users WHERE name='$name'";
      $result = mysql_query($result) or die(mysql_error());
      if ($result) {
        while ($row = mysql_fetch_array($result)) {
          echo $row['name']; // Output all information.
        }
      }
      else {
        echo 'Error with query: '.$query.'<br>'.mysql_error();
      }
    }
    else {
      echo 'You must specify a name.';
    }
    ?>
    [/code]
  2. ^ the buffer has a size limit and is not recommended. Instead you should learn how to do it correctly without them.

    Firstly, I can't remember how to use cookies. I've always used sessions. They're not only more secure...but they're better. :) It's easy to switch from cookies to sessions, so if ya want to do that I can help you there. :)
  3. Your site STILL has that dreadful green text. Please please please get rid of it.

    As for generating money, why not put some google ads on there? Seriously, they do work!

    When my site launches this coming winter, I could give you a link if you want.
  4. Exactly how much javascript should you know before trying to use AJAX? I know absolutely no javascript, but I'd love to use it.

     

    And is this something AJAX could do: Say you have a shop online where people buy with little points they accumulate for doing things. Then whenever a shop item is bought it disappears from the page without having to reload the page?

     

    How hard is it to incoporate PHP and AJAX to work together?

  5. I think you should try a neutral background color (maybe a light beige or gray) and then possible color schemes:
    - Burgandy, red, slate gray
    - Dark green, sage, white, grey
    You'll want to make sure your header matches.

    Instead of using image rollovers, have you ever considered using Flash? They're really easy to do and quite a bit more flexible. If you need the program, let me know. I've got both MX 2004 pro and 8.
  6. Depends.

    If you have PHP installed on the server, you have to upload the page to see the PHP. You can still edit it with dreamweaver, but you can't test it offline.

    If you have PHP installed on your computer, you can test your page before taking it online by using http://localhost/. Packages like WAMP5 and XAAMP will automatically install and configure PHP, mySQL, phpmyadmin, etc. to work together.
  7. Here's something really quick ($dbc is the variable of your connection to a database):

    [code]
    <?php

    // This is a function to prevent MYSQL injection
    function escape_data ($data) {
      global $dbc; // Need the connection.
      if (ini_get('magic_quotes_gpc')) {
        $data = stripslashes($data);
    }
    return mysql_real_escape_string($data, $dbc);
    }

    if (isset($_POST['submitted'])) {
      $errors = array();
      if (empty($_POST['name'])) {
        $errors[] = 'You did not enter a name!';
      }
      else {
        $name = escape_data($_POST['name']);
      }
      if (empty($errors)) {
        $query = "INSERT INTO tablename (name, address, city, state, zipcode, message) VALUES ('$name', '$address', '$city', '$state', '$zipcode', '$message')";
        $result = mysql_query($query) or die(mysql_error());
        if ($result) {
          echo 'Thankyou '.escape_data($name).' for filling out the form!';
        }
        else {
            echo mysql_error();
        }
      }
      else {
        foreach ($errors as $msg) {
          echo '<li> '.$msg.'</li>';
        }
      }
    }
    else {
       // Show the form
       echo '<form action="thisfile.php" method="post">
       <b>Name:</b> <input type="text" name="name" size="30">
       <input type="submit" name="submit" value="Submit">
      <input type="hidden" name="Submitted" value="TRUE"></form>';
    }

    ?>
    [/code]

    I don't have time to put in all the name, address, etc. but you can just copy and paste the part I did for name. Also, you should add something for your zipcodes making sure they're numbers like so:

    [code]<?php

    if (!is_numeric($_POST['zipcode'])) {
      $errors[] = 'Invalid zipcode';
    }

    ?>[/code]

    As for making a drop down, you're going to be writing quite a bit, but this is the basic syntax:

    [code]
    <select name="state">
      <option value="AL">Alabama</option>
      <option value="AK">Alaska</option>
      <option value="AZ">Arizona</option>
      <option value="AR">Arkansas</option>
    </select>[/code]

    Just keep going with all the states! Quite tedious, yes, but that's the way it is. :)

    I'm getting offline to eat dinner, but let me know if you need help and I'll answer when I can. Good luck with the script!
  8. Yes, but they specifically don't use his fame to promote their band. They prefer to allow the music to speak for itself, which is something I really do admire.

    Jared is both a talented actor and musician, but I definately prefer his music (all his movies made so far have been rated R, therefore the only acting I've got to go on is his role in "My So-Called Life").
  9. You mean a file manager you have set up on your server where people can download files? If a user can upload a PHP and and download PHP files, then yes it will be the actual code.

    If you mean just going to the PHP page and saves the page their viewing, they get nothing but HTML.
  10. For error checking you can do something like this:

    <?php
    if (isset($_POST['submitted'])) {
      $errors = array();
      if (empty($_POST['value'])) {
        $errors[] = 'You left value blank!';
      }
      else {
        $value = $_POST['value'];
      }
      if (empty($errors)) { // No errors occured
        // Do the query and such
      }
      else {
        foreach ($errors as $msg) {
          echo '<li> '.$msg.'</li>';
        }
      }
    }
    else {
        // Show the forum
    }
    ?>

    Then in your form just make a hidden input named "submitted" and the value TRUE. It's pretty simple.

    You'll need to use a regular expression to check for a valid email address. We've got a forum here just for regular expressions you should check out!

    EDIT:
    Oh, and it's not that your script wont work, it just seems ridiculously long for something that SHOULD be simple. What exactly are you trying to accomplish?

    + Instead of doing a random code, you could just use regular random words--they're easier for the end user to type in and just as secure IMO.
×
×
  • 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.