Jump to content

jawinn

New Members
  • Posts

    9
  • Joined

  • Last visited

    Never

Posts posted by jawinn

  1. I have a web form that dumps form data into a DB. One of the fields is for email address. I would really like the form to kick back an error message if an email address is used that is already in the DB. My DB only has one table. What would the code be for that?

    Thanks in advance,
    J
  2. I want to be able to change the header of a page in order to redirect users to a thankyou.php page.  Here's my setup.  I have index.php that has a form on it.  The form uses a processor called answer.php.  The processor sends the form's data to a database.  I used to just have the form data emailed to me and the users were successfully redirected to the thankyou.php page.  I want to be able to have the form data sent to the DB AND redirect the visitors to the thank you page.  Is there anything different I need to do with my original headers to make this happen.  If I need to post the code just let me know.

    thanks in advance,
  3. Ok, here's my next problem.  I want to be able to add records to a MySQL table via a web form.

    Here is my form code:

    <form method="post" action="answer.php" />
    First Name&nbsp;&nbsp;&nbsp;Last Name<br>
    <input type="text" name="fname" /><input type="text" name="lname" /><br/><br>
    City&nbsp;&nbsp;&nbsp;State<br>
    <input type="text" name="city" /><select name="state" />
    <option>Alabama</option>
    <option>Wyoming</option>
    </select><br/><br>
    E-mail Address<br>
    <input type="text" name="email" /><br/><br>
    Answer: <input type="radio" name="answer" value="A" /> A<input type="radio" name="answer" value="B" /> B<input type="radio" name="answer" value="C" /> C<input type="radio" name="answer" value="D" /> D<br/>
    <input type="checkbox" name="remember" value="1" />Remember Me<br/><br/>
    <input type="submit" name="submit" value="Submit" />
    </form>

    Here is my processor code:
    <?php

      include('conn.php');

        $error = false;

    if(isset($_POST['submit'])) {

    $form = array();
    $form['fname'] = $_POST['fname'];
    $form['lname'] = $_POST['lname'];
    $form['email'] = $_POST['email'];
    $form['city'] = $_POST['city'];
    $form['state'] = $_POST['state'];
    $answer = $_POST['answer'];

    if(!ini_get('magic_quotes_gpc')) {
    // Build safe query values string
    foreach($form as $key => $value) {
    $form[$key] = mysql_escape_string($value);
    }
    }

    $query = "INSERT INTO centries (fname,lname,email,city,state,answer) VALUES ('{$form['fname']}', '{$form['lname']}', '{$form['email']}', '{$form['city']}','{$form['state']}', '{$form['answer']}',)";

    $result = $database->query($query);

    ?>

    Every time I submit the form I get this error:

    Parse error: parse error, unexpected $ in /xxx/xxx/xxx/xxx/answer.php on line 29

    Any help is much appreciated.

    Thanks in advance,
    Jawinn
  4. I'm trying to connect to a Godaddy MySQL DB using PHP. This is not a remote connection. This is on a shared account. Here is the code I'm trying to use. I have to be missing something.

    <?php

    // set your infomation.
    $hostname='server.servername.net';
    $username='name';
    $password='password';
    $dbname='dbname';

    // connect to the mysql database server.
    $link_id = mysql_connect ($hostname, $username, $password);
    echo "success in database connection.";

    // select the specific database name we want to access.
    $dbname=$username."_".$dbname;
    if (!mysql_select_db($dbname)) die(mysql_error());
    echo "success in database selection.";

    // add a table to the selected database
    $result="CREATE TABLE address_book (first_name VARCHAR(25), last_name VARCHAR(25), phone_number VARCHAR(15))";
    if (mysql_query($result)){
    echo "success in table creation.";
    } else {
    echo "no table created.";
    }

    ?>

    I keep getting in the browser:
    success in database connection.Access denied for user: 'name@%' to database 'dbname_dbname'

    Any help is much appreciated.
×
×
  • 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.