Jul 25, 2008

Insert Into Database - Radio Buttons and dropdown menus

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > HTML, XML etc..

free web hosting

Insert Into Database - Radio Buttons and dropdown menus

HmmZ
I am currently working on a registration page but I can't figure out a few things, wich all basically have the same thing in common

Radio Button:
In the registration form i have a gender selection and I want to input that into the database, I currently have the following:
CODE
<input type="radio" name="gender" value="1">Male
<input type="radio" name="gender" value="2">Female


In the registering file I put the following (edited for the question):
CODE
$SQL = "INSERT into go_logintable(gender ) VALUES ('$gender')";


I have no idea if thats the right way to go, so please give me some pointers.
____________________________________
Dropdown Menu:
In the registration form i also have a birthdate selection and I want to input that into the database, I currently have the following:
CODE
<select name="birthDAY">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>


In the registering file I put the following (edited for the question):
CODE
$SQL = "INSERT into go_logintable(birthDAY ) VALUES ('$bday')";


Also here, I have no idea if thats the right way to go, so please some pointers here.

____
Basically its inserting the selections in the database, and I have no idea how to do it, what I wrote above, were just logically wroten lines (logical to my opinion), but I need feedback on it. (Register Page)

 

 

 


Reply

HmmZ
*BUMP*

Could someone please answer?>.<

Reply

Carsten
First, what is the table field you want to put your birthday data in? I suppose it is birthDAY (why the uppercases in day?). The variable where the birthday is stored also is named $birthDAY, because birthDAY is the name of the <select> form element.

To get a working piece of MySQL code, change your
CODE
$SQL = "INSERT INTO go_logintable (birthDAY) VALUES ('{$birthDAY}')";

Reply

HmmZ
well, ill show you what I have right now in the reguser file:
CODE
<?php
include "connect.php";
$password=$_POST['password'];
$password2=$_POST['password2'];
$username=$_POST['username'];
$fullname=$_POST['fullname'];
$gender=$_POST['gender'];
$birthday=$_POST['birthday'];
$birthmonth=$_POST['birthmonth'];
$birthyear=$_POST['birthyear'];
$country=$_POST['country'];
$email=$_POST['email'];
$email2=$_POST['email2'];

if (!$password==$password2) {
print "Your Confirm Password didn't match the original password";
}
if (!$email==$email2) {
print "Your Confirm E-Mail didn't match the original E-Mail";
}
else {
 $password=md5($password);
 $SQL = "INSERT into s_logintable(username, password, fullname, gender, birthday, birthmonth, birthyear, country, email) VALUES ('$username','$password','$fullname','$gender','$birthday','$birthmonth','$birthyear','$country','$email')";
 mysql_query($SQL);
 print "registration successful";
}
?>


If thats the right way to do it, please say so, also, i am not sure about the registration page, with the radio buttons and the dropdownmenu
This is what Ive done with the dropdownmenu "birthday"
CODE
<select name="birthday" style="background-color: #000000;
font size=10; color:#D80202; text-decoration: bold;" size="1" border="0">
<option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option>
<option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option>
<option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option>
<option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value=27">27</option><option value="28">28</option>
<option value="29">29</option><option value="30">30</option><option value="31">31</option>
</select>


and this the radiobuttons part:
CODE
<input name="gender" type="radio" value="1"><font size="2"><b>Male<input name="gender" type="radio" value="2">Female


I dont know if the code in the registering file (process file) will automatically select the selected value (ie birthday=31, the insert into database code puts in the birthday field the value 31 automatically)

As ive said before, im not sure what im doing here.

 

 

 


Reply

Carsten
I improved your reguser file. I am pretty sure it will worked, but I haven't checked. I don't have much time to go into detail about what I changed, but if you really feel you need more comment and after you looked at the php manual for it you can ask me. Anyway, This is the result:
CODE
<?php
include "connect.php";

if ($_POST)
{
extract($_POST);

if ($password != $password2)
{
 echo "Your Confirm Password didn't match the original Password";
}
elseif ($email != $email2)
{
 echo "Your Confirm Email didn't match the original Email";
}
else
{
 $password = md5($password);

 $sql = "INSERT INTO s_logintable (username, password, fullname, gender, birthday, birthmonth, birthyear, country, email)
   VALUES ('{$username}', '{$password}', '{$fullname}', '{$gender}', '{$birthday}',  '{$birthmonth}',  '{$birthyear}', '{$country}', '{$email}')");

 if (mysql_query($sql))
 {
  echo "Registration successful";
 }
 else
 {
  echo "Something went wrong";
 }
}
}
?>

The html for your dropdown box seems correct, it could need some cleaning though. Your radiobuttons part was also correct, though this is more valid:
CODE
<input name="gender" type="radio" value="1" />Male
<input name="gender" type="radio" value="2" />Female
Good luck with your script!

Reply

HmmZ
Thanks for the fast reply, hope it works =)

To understand it later on:
if ($_POST)
{
extract($_POST);

whats that for?

Reply

HmmZ
Just another quick question

Of course I need to create a table for the database and im unsure what the table needs (the ones i am not sure of are made red-colored)

CREATE TABLE go_logintable (
ID int(10) NOT NULL auto_increment,
username varchar(20) NOT NULL unique '',
password varchar(20) NOT NULL default '',
fullname varchar(40) NOT NULL default",
gender bit NOT NULL default",
birthday datetime NOT NULL default",
birthmonth datetime NOT NULL default",
birthyear datetime NOT NULL default",

country varchar(25) NOT NULL default",
email varchar(50) NOT NULL default",
PRIMARY KEY (ID)
)

Reply

Carsten
Replace the first part of your red table rows with this:
CODE
gender smallint(1) NOT NULL default,
birthday smallint(2) NOT NULL default,
birthmonth smallint(2) NOT NULL default,
birthyear smallint(4) NOT NULL default,
Also, I would recommend to remove your double quotes in there.

if($_POST) checks whether or not a form has been submitted to your registration page. When you submit your form, an array is created called $_POST. This array contains all your form values, like $_POST['password'].

extract($_POST) extracts all array keys as values. This means that $_POST['password'] becomes $password.

Reply

HmmZ
Ok big thanks for the help Carsten

Ill be needing more help later maybe, I know little by little how to work, but sometimes I just bounce to some problems.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : insert, database, radio, buttons, dropdown, menus

  1. Need Help With My Database [resolved]
    retrive data as a link (6)
  2. Is The Database System Gone Again? [resolved]
    Errors on PHPMyAdmin again (12)
    I wonder if there is a problem with the PHPMyAdmin system again? When trying to get into it, I once
    again get the following: QUOTE Warning: session_write_close() : SQLite: session write query
    failed: database is full in /usr/local/cpanel/base/3rdparty/phpMyAdmin/index.php on line 42
    Warning: session_write_close() : Failed to write session data (sqlite). Please verify that the
    current setting of session.save_path is correct
    (/var/cpanel/userhomes/cpanelphpmyadmin/sessions/phpsess.sdb) in
    /usr/local/cpanel/base/3rdparty/phpMyAdmin/index.php on line 42 Warning: Ca....
  3. Shoutcast Radio On Trap17
    Possible? (5)
    When I get my hosting here (again), will it be possible to host a shoutcast radio on the site? I was
    wondering because I really wanted to set up a radio and those other free hosting sites wouldn't
    let me. Thanks!....
  4. Database Or Pdf
    Best way to list books on my site (1)
    Hi all, I am not sure if this is the right place to post but I'm sure you'll tell
    me if it's not. My problem is this: I have a website where I sell books and it's one of
    those simpleton sites where I don't need to know code, I just click icons etc Anyway, I can
    upload images to the server and need to have them in different resolutions and link from a thumbnail
    to the larger picture. What I am trying to say is I have about 6000 books to display on my
    website which is impractical as it takes me about 10 mins to load 1 copy. What is the ....
  5. Please Explain Me Mysql
    How do i insert information into this config: (4)
    Hi, I wanted to try just to test how can i connect my website to another mysql server, but i have no
    idea how to insert the other mysql information such as port and host etc.... so here is the config
    file please give me an example CODE <?php // mySQL information $server =
    'FRESHSQL.COM:3306';                   // MySql server $username =
    'vasilevich';                      // MySql Username $password =
    '*******';                         // MySql Password $database =
    'vasilevich';                  // MySql Da....
  6. Phpmyadmin
    Create new database: No Privileges (6)
    i can not make a sql for diff srcipt, but the sricpt i have is php, DJ-cpanel.. all tho i can not
    install it the error is like this Creating Database Tables No database selected there a mysql
    database is made, but i can not use it for othere stuff... plz note that this is Free script and not
    for paid.. is there a way that the myqsul can not use sql other scripts? or it maybe not working...
    but i am not sure if the script not working or it can be the server may be down on mysql...? ....
  7. How To Manage The Database For E-books Website In My Sql?
    (3)
    I wanna know how to manage the database for website of e-books with forum in it, n the database is
    in mysql. PLZ HELP ME!....
  8. I Need Help Transferring Sql Database?
    (3)
    ok so i am trying to transfer mediawiki's but i am having trouble with exporting importing the
    database. I am using phpmyadmin on both sides of the hosts. When i do the import i get this.
    QUOTE SQL query: -- -- Database: `apolopedia` -- CREATE DATABASE `apolopedia`
    DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci; MySQL said: Documentation #1044 - Access
    denied for user 'jaenagle'@'localhost' to database 'apolopedia' I tried to
    give my user all rights, but it gave me this also. QUOTE SQL query: GRANT A....
  9. Horribly Inefficient
    Bananna clips at Radio Shack (0)
    I mess around with remote controlled model airplanes in my free time. I have a flight box with a
    nice panel hook up for a battery i use to start the motors on my planes. the panel has bananna plug
    recepticles on it. long story short, my charger leads are alligator clips and i did not feel like
    taking the battery out of the field box. so i decided to make an adapter of sorts using some
    bannana clips from radio shack. after i got to the store, i looked for about five minutes for the
    kind i wanted, then i ended up asking someone and still could not find them. i ende....
  10. Flash Problem
    sometimes the buttons will load the wrong link. (9)
    Its weird but sometimes when you hit the forums or roster button on my flash banner it will load:
    www.childrenofconan.trap17.com/index.html instead of what its suppost to. It works fine, but if you
    mess around and click the buttons for a little bit you will notice this happening. This is a problem
    because people visiting the site will sometimes click the button once and be like oh I guess the
    link is broken and never come back, if anyone has a solution to what could be the problem it would
    be awesome. This is one of my first custom flash banners and im just confused what....
  11. Ms-access Database Question
    Allowing Web Access to the Informaton (3)
    Hi. I wanna know if there is a way of accessing an MS-Access database so that my site can extract
    data from it and make it avilable online. I have an accounting package that saves everthing in an
    MDB file and I want that info available for my clients from whereever thay are. Split Topic ....
  12. Technicolor
    A Would-be Internet Radio Show Website (0)
    "Technicolor" was an idea for a comedy website that made use of late 30s to early 60s American
    culture (as inspired by such games as Fallout and Bioshock) which would touch on such issues as
    racism, sexism, politics, religion, and other such somewhat hot topics. The website itself is
    intended to be designed similarly to a to an older poster or advertisement, and I think it shows
    with the way that I depicted the colors, shapes and various other images. The navigation buttons
    were simply things I found via a google search, then used some Photoshop techniques to dull them i....
  13. Portable Internet Radio Receivers
    Something new (0)
    I heard yesterday that there are some portable internet radio players, so I'm very confused how
    is it possible? Because that kind of player should have some kind of internet conection, right? If
    something like that is possible that would be great because FM radio station have high noise sound.
    And FM radio has over 50 years, it is very old technology. So are there some ideas how did they do
    that, to make internet radio portable and should there be any other element excluding that radio
    player?....
  14. Index In A Mysql Database
    Make the numbers follow (3)
    I hope I am on topic here (It does have to do with web design, after all). I have noticed that in a
    MySQL database, the 'id' field just keeps its numbers for every record, with the backdraw
    that, whenever you remove (a) record(s) from the table, you get your list numbered as eg.
    1,5,6,7,12,25 etc. This makes it a bit difficult of keeping track of the number of records in your
    table. Is there a way of achieving (either in PHPMyAdmin or through the use of PHP) that the id
    field in your table gets sort of 'refreshed and updated' so you have a clearer view....
  15. Transferring From Old Server To New Server "database And Forum" [resolved]
    I'm in need of aid from admin in transferring phpbb database and f (5)
    Ok, I have a question and would preferable ask if its possible as well. Currently I have a phpbb
    forum (version 2) placed among another server. Thing is I would like to import it among my trap17
    account, as this is the place I intend to stay as its so great. Problem is I have about 40+ users
    already registered among that forum and have several mods implemented within it as example Cash Mod,
    Jobs Mod, Rank Banners etc and fiblack template. I have tried using a few guides in trying to copy
    my database over here but to no avail it is rendered useless. So in short is there a....
  16. Getting Started With Mysql
    creating tables and insert data into them. (2)
    Hi in this tutorial you will learn how to create tables and insert items into them. First steps are
    to create the database - go into your cpanel and mysql databases, from there make an account and a
    database and then attach them together with all priviliges, call the database test and the account
    admin, with the pw as pass - or any other password. We need to connect to the database so first in
    your php file (probably named index.php) - this is how to do it. CODE
    mysql_connect("localhost", "admin", "pass") or
    die(mysql_error(&....
  17. What Value Would I Use To Insert This Data?
    Help on insertion of data to database? (4)
    I am learning slowly but surely and I know some of you probably getting tired of my questions. ^^;;
    However, I believe one can not learn without asking questions. So.. if I get too bothersome.. just
    point me to some books or something. lol XD // Make a MySQL Connection mysql_connect("localhost",
    "name", "password") or die(mysql_error()); mysql_select_db("at2927_abq") or die(mysql_error()); //
    Insert a row of information into the table "example" mysql_query("INSERT INTO members (pasture)
    VALUES('Timmy Mellowman', '23' ) ") or die(mysql_error()); ....
  18. Database With Mysql++
    getting mySQL++ to work with trap17 (7)
    Hi, I'm trying to build an online game and figured the easiest way to do the server list would
    be to make a mySQL database for it; however, I use the con() command on the IP i get from pinging my
    website and I always get an abnormal program termination; however, it will work with the mySQL on my
    own machine. The code is below: CODE #include <iostream> #include <iomanip>
    #include <mysql++> #include "pass.h"//holds my password (i program at
    school) int main(void) {     Connection con("t3jem3_test","....
  19. Adding Drop Down Menus
    (4)
    I have looked around many IPB support sites, but I didn't find a suitable drop-down menu add-on
    that I liked or worked correctly. I have noticed the drop down menus on this forum on other forums,
    and I was wondering if this was custom to this site or there was a tutorial somewhere which shows
    how to make one similar to this? Or if anything, I basic IPB drop down menu tutorial/add on.
    Thanks.....
  20. Internet Radio?
    (7)
    hey, anyone know of a free program for streaming radio over the internet? i've tried shoutcast
    and winamp but the live feeding is no good. streaming prerecorded files is ok, but are there any
    that stream live? (or at least somewhat live?)....
  21. Truefusion Shoutbox
    No Database required! (31)
    After several tests, i think it's good enough to be released. Please report any problems in
    this topic. About the shoutbox: QUOTE It's supports many bbcodes that we're all used
    to. Over 60 smileys. No database required for shout storage: All stored on flatfile. XHTML valid.
    Installation is basically extract files, and chmod the files "shouts.log", "ipban.log",
    "wordfilter.log" 666. Compatible with standard-compliant browsers, and Internet Explorer. Admin
    Cpanel: Edit/delete shouts, IP ban/unban, Word Filter. Users can delete/edit their shouts within a....
  22. Tales Of "insert Your Rpg Title" Game Collection
    (5)
    I'm probably gonna end up getting all of them if I can. Tales of Eternia - PSP Tales of
    Legendia - PS2 Tales of The Tempest - DS Tales of Phantasia - GBA Tales of Symphonia - GC Still
    havn't played Symphonia. @_@ They're really good if your into a good RPG series and want a
    challenge of sorts.....
  23. Logitech G15 Keyboard
    Macro Buttons (5)
    I recieved the Logitech G15 keyboard this past christmas, and i'm wondering who else uses it. I
    really love the backlit keys, and the LCD, but has anyone got the macro buttons to work properly?
    Windows does not register them as an actual key, the program seems to register it, and spit out the
    macro. I can't use it for actual gaming, like counter-strike because there is no practical way
    to bind it. Link is here: http://www.logitech.com/index.cfm/products...CONTENTID=10717 ....
  24. Multiple Drop Down Menus W/ Submit Button
    (6)
    I am building a page that will have 2 drop down menus and a submit button. The first menu will have
    one set of options, say colors (red, blue, green, yellow). The second menu will have another set of
    options, say sizes (small, medium, large). What I want to be able do is select a color and a size,
    click submit and have it go to the page for those options. So if a user picks 'Red' and
    'Small' and clicks submit they will be linked to page1.html. If they pick 'Blue' and
    'Large', they will be linked to page2.html, and so on. Any ideas how to ....
  25. Can You Add Images Into A Mysql Database?
    Using Php? (20)
    I'm learning php in class right now, but I'm still not that good at it, what I'm
    wondering is when I write the php so that it can connect with a database, can I at the same time
    have it that it is able to display back images that I choose. Like, I want a search feature, where
    you can search for a keyword, and it will bring back a list of all the possible entries with that
    keyword, but each of these entries will have a photo associated with it. Now, do I put these image
    files directly into the database, or do I write the code to link them from my files to th....
  26. Connect To Remote Oracle Database With Toad
    i'm lost (6)
    Hey gang, long time no see, my bad! Anyway, I got me a question. Does anybody know how to
    connect to a remote oracle database using toad? When I read the docs for toad I get the impression
    that I have to have a local oracle installation in order to use toad, but that just seems silly. I
    guess I'm stuck at the point of trying to figure out how to tell toad where to look for all of
    the configuration information it needs for the connection if I don't have any "Oracle Home"
    directories. :crosses fingers: Peace!....
  27. Mysql Database Size
    related to the free database space (6)
    hi all! this is my first post /biggrin.gif' border='0' style='vertical-align:middle'
    alt='biggrin.gif' /> and i have a doubt, how much mysql space i am allowed to use... i mean how
    much is available for my free account....
  28. Import From Excel File Into Mysql Database
    (7)
    Has anyone tried using the excel import function that comes with phpmyadmin
    http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
    is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
    to import the data to , there is a link on the bottom left corner which says "insert data from a
    text file into the table" - although it says text file it still can be used to import an excel file.
    When you click on this link you will be taken to a page where you will be asked for the file name
    (the....
  29. Radio Button
    (4)
    I am trying to maintain the radio button selection on a Submit, but the form refreshes to its
    default selection. BTW, After a Submit is clicked, the radio form stays visible on the top of the
    screen while the query results are displayed on the bottom half of the screen (we're using an
    internal, embedded link). That's when the default selection comes into place. Any help would be
    appreciated. Please respond Kvarnerexpress.....
  30. Change Font Size On Taskbar Buttons
    (4)
    Would you like larger fonts on your taskbar buttons? Maybe you're a little short sighted, or
    just want to mess about a bit:) Here's how to do it... 1. Right click anywhere on your Desktop
    (not on an icon) and the context menu appears. 2. From the context menu, select Properties, and the
    Display Properties window appears. 3. Select the "Appearance" tab by clicking on it once. 4.
    Select the "Active Title Bar" from the "Item:" drop down list. 5. Adjust the font size, color,
    bold, or italics using the selectors to the right of the font box. 6. Click Apply to ....

    1. Looking for insert, database, radio, buttons, dropdown, menus

Searching Video's for insert, database, radio, buttons, dropdown, menus
Similar
Need Help
With My
Database
[resolved] -
retrive data
as a link
Is The
Database
System Gone
Again?
[resolved] -
Errors on
PHPMyAdmin
again
Shoutcast
Radio On
Trap17 -
Possible?
Database Or
Pdf - Best
way to list
books on my
site
Please
Explain Me
Mysql - How
do i insert
information
into this
config:
Phpmyadmin -
Create new
database: No
Privileges
How To
Manage The
Database For
E-books
Website In
My Sql?
I Need Help
Transferring
Sql
Database?
Horribly
Inefficient
- Bananna
clips at
Radio Shack
Flash
Problem -
sometimes
the buttons
will load
the wrong
link.
Ms-access
Database
Question -
Allowing Web
Access to
the
Informaton
Technicolor
- A Would-be
Internet
Radio Show
Website
Portable
Internet
Radio
Receivers -
Something
new
Index In A
Mysql
Database -
Make the
numbers
follow
Transferring
From Old
Server To
New Server
"databa
se And
Forum"
[resolved] -
I'm in
need of aid
from admin
in
transferring
phpbb
database and
f
Getting
Started With
Mysql -
creating
tables and
insert data
into them.
What Value
Would I Use
To Insert
This Data? -
Help on
insertion of
data to
database?
Database
With Mysql++
- getting
mySQL++ to
work with
trap17
Adding Drop
Down Menus
Internet
Radio?
Truefusion
Shoutbox -
No Database
required!
;
Tales Of
"insert
Your Rpg
Title"
Game
Collection
Logitech G15
Keyboard -
Macro
Buttons
Multiple
Drop Down
Menus W/
Submit
Button
Can You Add
Images Into
A Mysql
Database? -
Using Php?
Connect To
Remote
Oracle
Database
With Toad -
i'm lost
Mysql
Database
Size -
related to
the free
database
space
Import From
Excel File
Into Mysql
Database
Radio Button
Change Font
Size On
Taskbar
Buttons
advertisement



Insert Into Database - Radio Buttons and dropdown menus



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE