Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,162 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,876 people online right now. Registration is fast and FREE... Join Now!




registration form

 
Reply to this topicStart new topic

registration form, using php and mysql

jojodalde
3 Jan, 2008 - 07:55 PM
Post #1

New D.I.C Head
*

Joined: 3 Jan, 2008
Posts: 10

hi guys, i have this code and and in my database, i want these m_dbirth, d_dbirth and y_dbirth to be as 1 field with "date" type of data, variable named "dbirth" can anyone help me???? thanks!

CODE

<html>
<head></head>
<body bgcolor="pink">
    <br><br><br>

    <table width="600" border="0" align="center" cellpadding="3" cellspacing="0">
        <tr>
            <td><strong><font face="arial"color="gray">Pinkbox Registration</font></strong></td>
        </tr>
    </table>
    </table>
    <table width="600" border="0" align="center" cellpadding="3" cellspacing="0">
    <tr>
        <td align=left><strong>
        <a href="club_members.php"><font face=arial narrow size=1>VIEW PINKBOX CLUB</font></a>  |  <a href="welcomeadmin.php"><font face=arial narrow size=1>ADMIN</font></a>
          |  
        <a href="logout.php"><font face=arial narrow size=1>LOG OUT</font></a>
        </strong></td>
    </tr>
    </table>

    <table width="600" border="1" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
        <tr>
            <form id="form1" name="form1" method="post" action="addclub_members.php">
            <td>
                <table width="600" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
                    <tr>
                        <td align=right><font face="arial">Branch Code</font></td>
                        <td width="14">:</td>
                        <td width="400"><input name="bcode" type="text" id="bcode" size="40" maxlength="4"/></td>
                    </tr>
                    <tr>
                        <td align=right><font face="arial">ID Number</font></td>
                        <td>:</td>
                        <td><input name="idno" type="text" id="idno" size="40" maxlength="13" /></td>
                    </tr>
                    <tr>
                        <td align=right><font face="arial">Name</font></td>
                        <td valign="top">:</td>
                        <td><input name="name" type="text" id="name" size="40" /></td>
                    </tr>
                    <tr>
                        <td align=right><font face="arial">Address</font></td>
                        <td valign="center">:</td>
                        <td><textarea name="address" cols="50" rows="3" id="address"></textarea></td>
                    </tr>
                    <tr>
                        <td align=right><font face="arial">Date of Birth</font></td>
                        <td valign="top">:</td>
                        <td><select name="m_dbirth">
                                <option value="">Month</option>
                                <option value="01">Jan</option>
                                <option value="02">Feb</option>
                                <option value="03">Mar</option>
                                <option value="04">Apr</option>
                                <option value="05">May</option>
                                <option value="06">Jun</option>
                                <option value="07">Jul</option>
                                <option value="08">Aug</option>
                                <option value="09">Sep</option>
                                <option value="10">Oct</option>
                                <option value="11">Nov</option>
                                <option value="12">Dec</option>
                        </select>
                        <select name="d_dbirth">
                                <option value="">Day</option>
                                <option value="01">01</option>
                                <option value="02">02</option>
                                <option value="03">03</option>
                                <option value="04">04</option>
                                <option value="05">05</option>
                                <option value="06">06</option>
                                <option value="07">07</option>
                                <option value="08">08</option>
                                <option value="09">09</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>
                        <select name="y_dbirth">
                                <option value="">Year</option>
                                <option value="2020">2020</option>
                                <option value="2019">2019</option>
                                <option value="2018">2018</option>
                                <option value="2017">2017</option>
                                <option value="2016">2016</option>
                                <option value="2015">2015</option>
                                <option value="2014">2014</option>
                                <option value="2013">2013</option>
                                <option value="2012">2012</option>
                                <option value="2011">2011</option>
                                <option value="2010">2010</option>
                                <option value="2009">2009</option>
                                <option value="2008">2008</option>
                                <option value="2007">2007</option>
                                <option value="2006">2006</option>
                                <option value="2005">2005</option>
                                <option value="2004">2004</option>
                                <option value="2003">2003</option>
                                <option value="2002">2002</option>
                                <option value="2001">2001</option>
                                <option value="2000">2000</option>
                                <option value="1999">1999</option>
                                <option value="1998">1998</option>
                                <option value="1997">1997</option>
                                <option value="1996">1996</option>
                                <option value="1995">1995</option>
                                <option value="1994">1994</option>
                                <option value="1993">1993</option>
                                <option value="1992">1992</option>
                                <option value="1991">1991</option>
                                <option value="1990">1990</option>
                                <option value="1989">1989</option>
                                <option value="1988">1988</option>
                                <option value="1987">1987</option>
                                <option value="1986">1986</option>
                                <option value="1985">1985</option>
                                <option value="1984">1984</option>
                                <option value="1983">1983</option>
                                <option value="1982">1982</option>
                                <option value="1981">1981</option>
                                <option value="1980">1980</option>
                                <option value="1979">1979</option>
                                <option value="1978">1978</option>
                                <option value="1977">1977</option>
                                <option value="1976">1976</option>
                                <option value="1975">1975</option>
                                <option value="1974">1974</option>
                                <option value="1973">1973</option>
                                <option value="1972">1972</option>
                                <option value="1971">1971</option>
                                <option value="1970">1970</option>
                    </select></td>
                    </tr>
                    <tr>
                        <td align=right><font face="arial">Branch</font></td>
                        <td valign="top">:</td>
                        <td><input name="branch" type="text" id="branch" size="40" maxlength="20" /></td>
                    </tr>
                    
                    <tr>
                        <td align=right><font face="arial">School</font></td>
                        <td valign="top">:</td>
                        <td><input name="school" type="text" id="school" size="40" /></td>
                    </tr>

                    <tr>
                        <td align=right><font face="arial">Contact Number</font></td>
                        <td valign="top">:</td>
                        <td><input name="contact_num" type="text" id="contact_num" size="40" /></td>
                    </tr>
                    <tr>
                        <td align=right><font face="arial">Email</font></td>
                        <td valign="top">:</td>
                        <td><input name="email" type="text" id="email" size="40" maxlength="30" /></td>
                    </tr>

                    <tr>
                        <td> </td>
                        <td> </td>
                        <td><input type="submit" name="Submit" value="Submit" /> <input type="reset" name="Submit2" value="Reset" /></td>
                    </tr>
                </table>
            </td>
            </form>
    </tr>
</body>
</html>

*edit: Please use code tags in the future. Thanks! code.gif

This post has been edited by Martyr2: 3 Jan, 2008 - 08:31 PM
User is offlineProfile CardPM
+Quote Post

snoj
RE: Registration Form
3 Jan, 2008 - 08:04 PM
Post #2

$Null
Group Icon

Joined: 31 Mar, 2003
Posts: 3,304



Thanked: 6 times
Dream Kudos: 700
My Contributions
What the problem?
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Registration Form
3 Jan, 2008 - 08:38 PM
Post #3

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,199



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
You just need to concatenate them together during the processing of the script. Remember you get access to each value of the form using $_POST so you can do something along the lines of....

CODE


$birth = $_POST['m_dbirth'] . "/" . $_POST['d_dbirth'] . "/" . $_POST['y_dbirth'];



Then validate the variable $birth to see if it is a correct date and insert it into your database once it has been validated. You could validate each piece using a function like checkdate before you put them together. You could also create a timestamp using mktime etc.

But that is how you would go about doing it depending on your implementation and goal. Hope that helps.

Enjoy!

"At DIC we be birthday creating code ninjas!" decap.gif

User is online!Profile CardPM
+Quote Post

jojodalde
RE: Registration Form
3 Jan, 2008 - 08:44 PM
Post #4

New D.I.C Head
*

Joined: 3 Jan, 2008
Posts: 10

i just want to know what php function will i use to merge the m_dbirth, d_dbirth and y_dbirth in 1 field in my database..
User is offlineProfile CardPM
+Quote Post

jojodalde
RE: Registration Form
3 Jan, 2008 - 08:51 PM
Post #5

New D.I.C Head
*

Joined: 3 Jan, 2008
Posts: 10

QUOTE(Martyr2 @ 3 Jan, 2008 - 09:38 PM) *

You just need to concatenate them together during the processing of the script. Remember you get access to each value of the form using $_POST so you can do something along the lines of....

CODE


$birth = $_POST['m_dbirth'] . "/" . $_POST['d_dbirth'] . "/" . $_POST['y_dbirth'];



Then validate the variable $birth to see if it is a correct date and insert it into your database once it has been validated. You could validate each piece using a function like checkdate before you put them together. You could also create a timestamp using mktime etc.

But that is how you would go about doing it depending on your implementation and goal. Hope that helps.

Enjoy!

"At DIC we be birthday creating code ninjas!" decap.gif


ok ill try it..thanks!

User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Registration Form
3 Jan, 2008 - 08:53 PM
Post #6

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,199



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
Another nice little function you could play with is strtotime(). smile.gif
User is online!Profile CardPM
+Quote Post

jojodalde
RE: Registration Form
3 Jan, 2008 - 09:11 PM
Post #7

New D.I.C Head
*

Joined: 3 Jan, 2008
Posts: 10

ive tried it using the concat() but im having no output again..by d way heres my code. i dont know what exactly the problem is..can anyone help me?
CODE


<?php
$con = mysql_connect("localhost","pbclub","theclub");
    if (!$con)

      {

           die('Could not connect: ' . mysql_error());
      }

      mysql_select_db("pinkbox", $con);

$bcode=$_POST['bcode'];
$idno=$_POST['idno'];
$name=$_POST['name'];
$address=$_POST['address'];

$dbirth = $_POST['m_dbirth'] . "/" . $_POST['d_dbirth'] . "/" . $_POST['y_dbirth'];
$branch=$_POST['branch'];
$reg_date = $_POST['m_reg_date'] . "/" . $_POST['d_reg_date'] . "/" . $_POST['y_reg_date'];
$school=$_POST['school'];
$contact_num=$_POST['contact_num'];
$email=$_POST['email'];


$query="INSERT INTO club_members (bcode, idno, name, address, dbirth, branch, reg_date, school, contact_num, email) VALUES ('$bcode', '$idno', '$name','$address','$dbirth','$branch','$reg_date','$school','$contact_num','$email')";
$result=mysql_query($query);

if($result){
echo "Successful!";
echo "<BR>";
echo "<a href='club_members.php'><font face=arial size=2>View Club Members</font></a>"; // link to view guestbook page
}

else {
echo "
    <html>
    <head></head>
    <bgcolor=pink>
    <font face=bangle size=5><b>ERROR!</b>
    <br><br>
    <font face=arial narrow size=2><b>
    <a href='register.php'>back to registration</a>
    </b></font>
    </body>
    </html>
    ";
}

mysql_close();

?>


[mod edit] Please code.gif

This post has been edited by snoj: 7 Jan, 2008 - 06:50 AM
User is offlineProfile CardPM
+Quote Post

Martyr2
RE: Registration Form
3 Jan, 2008 - 10:29 PM
Post #8

Programming Theoretician
Group Icon

Joined: 18 Apr, 2007
Posts: 5,199



Thanked: 213 times
Expert In: C/C++, Java, VB, VB.NET, C#, PHP, Web Development, HTML & CSS, Javascript

My Contributions
well... go and debug it. Check to make sure that $dbirth is giving you the correct data. Comment out the mysql_query line to see if the query is messed up. Echo out the value of $query and see if the statement looks correct.

Make sure you are selecting a month and a day because I also notice that you have options with no value in those forms. If you are not seeing error messages or something, you either need to setup some error handling to write the error to a file or database, or you need to turn it on for display if the system is not yet in a production environment.

Using some very basic debugging techniques can isolate this problem really quick. Try some of them out. Show us the error message you are getting and we can help further. smile.gif
User is online!Profile CardPM
+Quote Post

jojodalde
RE: Registration Form
6 Jan, 2008 - 11:19 PM
Post #9

New D.I.C Head
*

Joined: 3 Jan, 2008
Posts: 10

i modfied my code below and i got this error message..i think that code i recently added was correct but i stil got an error.

Undefined index: d_birth in c:\program files\easyphp1-8\www\pinkbox\addclub_members.php on line 20




CODE
<?php
$con = mysql_connect("localhost","pbclub","theclub");
    if (!$con)

      {

           die('Could not connect: ' . mysql_error());
      }

      mysql_select_db("pinkbox", $con);

$bcode=$_POST['bcode'];
$idno=$_POST['idno'];
$name=$_POST['name'];
$address=$_POST['address'];

$dbirth = '0000-00-00';
    if(checkdate($_POST['m_dbirth'], $_POST['d_dbirth'], $_POST['y_dbirth'])) {
        $dbirth = $_POST['y_dbirth'] . '-' . $_POST['m_dbirth'] . '-' . $_POST['d_birth'];
    }
$branch=$_POST['branch'];

$reg_date = '0000-00-00';
    if(checkdate($_POST['m_reg_date'], $_POST['d_reg_date'], $_POST['y_reg_date'])) {
        $reg_date = $_POST['y_reg_date'] . '-' . $_POST['m_reg_date'] . '-' . $_POST['d_reg_date'];
    }


$school=$_POST['school'];
$contact_num=$_POST['contact_num'];
$email=$_POST['email'];


$query="INSERT INTO club_members (bcode, idno, name, address, dbirth, branch, reg_date, school, contact_num, email) VALUES ('$bcode', '$idno', '$name','$address','$dbirth','$branch','$reg_date','$school','$contact_num','$email')";
$result=mysql_query($query);

if($result){
echo "Successful!";
echo "<BR>";
echo "<a href='club_members.php'><font face=arial size=2>View Club Members</font></a>"; // link to view guestbook page
}

else {
echo "
    <html>
    <head></head>
    <bgcolor=pink>
    <font face=bangle size=5><b>ERROR!</b>
    <br><br>
    <font face=arial narrow size=2><b>
    <a href='register.php'>back to registration</a>
    </b></font>
    </body>
    </html>
    ";
}

mysql_close();

?>


[mod edit] Please code.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 11:53PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month