Form Processing..

2»

Comments

  • CannonBallGuyCannonBallGuy Moderator Shared Hoster
    I can't make a table. I have phpMyadmin and I have tried but I can't do it and I don't especially want to learn... Can someone give me the code to do it please?
  • dabossdaboss WP V.I.P. ''The Boss'' Administrator
    CBG, I think you'd just have to learn how to use the phpMyAdmin interface - unless you don't mind giving the ID/Password to someone to go in and create the table for you.

    It's actually very easy.
  • CannonBallGuyCannonBallGuy Moderator Shared Hoster
    It looks simple but I don't know what to put in all the fields...
    Could someone possibly code the database?
  • dabossdaboss WP V.I.P. ''The Boss'' Administrator
    Yes, I could code the SQL command to create the table. Have you created the database yet?

    1. Go to your admin panel and create the database.
    2. Tell me the database name
    3. Tell me the name of the host where the database is hosted
    4. Tell me how many fields you want and their attributes (e.g. Field Name = "First Name", Type = "Text", Length = "20")

    5. I'll send you the PHP that you can run against the database to create the table. However, you need to tell me the above (well, I can guess no. 4 from your html form).
  • CannonBallGuyCannonBallGuy Moderator Shared Hoster
    Okay...

    This is the bit of the php file that connect to the database:
    if($email1==$email2){ 
     $id_link=mysql_connect($kaziaz.com,$matsim68_PS2mall,$bugg3r); 
     mysql_select_db($matsim68_PS2mall); 
    
     $q="INSERT INTO TABLE NAME (name,age,email) VALUES('$name','$age','$email')";
    
    That has everything... :)
  • dabossdaboss WP V.I.P. ''The Boss'' Administrator
    CBG, cut and paste the code below into a new file with a PHP extension - e.g. createtable.php. Load it up into you server and call it using a browser - e.g. http://www.yourdomain.com/createtable.php

    Please fill in the blanks (e.g. <YOUR_DB_HOST>) before loading up to the server.

    Assumptions:
    1. I've assumed that you only have 3 fields (email, name, age) and than all the fields are text with a maximum field length of 50 characters.
    2. I've also assumed that email is the primary key.
    3. I've assumed the table name of CBG_TABLE (Please modify this to be something more descriptive for your purpose).
    <?php
    
    $db_host="<YOUR_DB_HOST>";
    $db_usr="<YOUR_DB_USR>";
    $db_pwd="<YOUR_DB_PWD>";
    $db_name="<YOUR_DB_NAME>";
    
    $id_link=mysql_connect($db_host,$db_usr,$db_pwd);
    mysql_select_db($db_name);
    
    $q="CREATE TABLE CBG_TABLE (EMAIL CHAR(50), NAME CHAR(50), AGE CHAR(50), PRIMARY KEY (EMAIL))";
    $r=mysql_query($q); 
    if(!$r) {
        $err=mysql_error();
        echo $err;
        exit();
    }
    else {
        echo "WooHoooo... Table created successfully. :)";
    }
    
    ?>
    


    Once you've create the table, in your process.php file, you should code the INSERT statement as follows:
    $q="INSERT INTO CBG_TABLE (email,name,age) VALUES('$email','$name','$age')";
    

    Hope it works!
Sign In or Register to comment.