Jump to content

Archived

This topic is now archived and is closed to further replies.

irene169

any1 can help me in this??

Recommended Posts

helo there....

i have some problem with my php scripts.....i dunno why the php that i run, it could not connect(i guess) to the database itself..coz..when i click submit..the input cannot be save into the database...wat's wrong it is i wonder....

hope some1 can help me in this...thanks...

here is my php script:


<html>
<head><title> User Sign UP</title></head>
<body bgcolor=f0fff0>

<p align="center">
<font size="10" face="rockwell extra bold"> <br>User Sign Up<br><hr> </h1>
</font>
</p>

<table>
<tr><td><font face="arial" size=5><b>Register:</b> Enter Information </font>
</td></tr>
<tr><td><font face="arial" size=3><b>Your Personal Information</b> - <font face="arial" size=2>All fields are required</font>
</td></tr>
</table>

<?php

if(!$_POST['submit'])
{
?>

<form action = "<?=$SERVER['PHP_SELF']?>" method="POST">

<p align="center">

<table>
<tr><td><font face="Arial">First Name : </font></td><td> <input type="text" size=20 name="fname"></td></tr>
<tr><td><font face="Arial">Last Name : </font></td><td> <input type="text" size=20 name="lname"></td></tr>
<tr><td><font face="arial"> Gender : </font></td>
<td> <input name="gender" type="radio" value="m"><font face="arial" size=2>Male</font><br>
<input name="gender" type="radio" value="f"><font face="arial" size=2> Female</font></td>
</tr>
<tr>

<td><font face="arial">Date of Birth:</font>
</td>

<td>
<select name="birthmonth">
<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="birthday">
<option value=""> -- day -- </option>
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">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>

<select name="birthyear">
<option value=""> -- year -- </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>
<option value="1969">1969</option>
<option value="1968">1968</option>
<option value="1967">1967</option>
<option value="1966">1966</option>
<option value="1965">1965</option>
<option value="1964">1964</option>
<option value="1963">1963</option>
<option value="1962">1962</option>
<option value="1961">1961</option>
<option value="1960">1960</option>
<option value="1959">1959</option>
<option value="1958">1958</option>
<option value="1957">1957</option>
<option value="1956">1956</option>
<option value="1955">1955</option>
<option value="1954">1954</option>
<option value="1953">1953</option>
<option value="1952">1952</option>
<option value="1951">1951</option>
<option value="1950">1950</option>
<option value="1949">1949</option>
<option value="1948">1948</option>
<option value="1947">1947</option>
<option value="1946">1946</option>
<option value="1945">1945</option>
<option value="1944">1944</option>
<option value="1943">1943</option>
<option value="1942">1942</option>
<option value="1941">1941</option>
<option value="1940">1940</option>
<option value="1939">1939</option>
<option value="1938">1938</option>
<option value="1937">1937</option>
<option value="1936">1936</option>
<option value="1935">1935</option>
<option value="1934">1934</option>
<option value="1933">1933</option>
<option value="1932">1932</option>
<option value="1931">1931</option>
<option value="1930">1930</option>
<option value="1929">1929</option>
<option value="1928">1928</option>
<option value="1927">1927</option>
<option value="1926">1926</option>
<option value="1925">1925</option>
<option value="1924">1924</option>
<option value="1923">1923</option>
<option value="1922">1922</option>
<option value="1921">1921</option>
<option value="1920">1920</option>
</select>
</td></tr>

<tr><td><font face="Arial">Street Address : &nbsp;&nbsp;&nbsp;&nbsp; </font> </td>
<td><input type="text" size=20 name="add1"></td><tr>
<tr><td></td><td><input type="text" size=20 name="add2"></td><tr>
<tr><td></td><td><input type="text" size=20 name="add3"></td><tr>

<tr><td><font face="Arial"> City:</font> </td><td> <input type="text"size=20 name="city"><br></td></tr>

<tr><td><font face="arial">Zip/ Postal Code :</font></td>
<td><input type="text" size=20 name="zcode"></td>
</tr>
<tr><td><font face="arial">Country : </font></td>
<td><select name="country"><option value=""> -- Country -- </option>
<option value="US">UNITED STATES</option>
<option value="CA">CANADA</option>
<option value="AF">Afghanistan</option>
<option value="AL">Albania</option>
<option value="DZ">Algeria</option>
<option value="AS">American Samoa</option>
<option value="AD">Andorra</option>
<option value="AO">Angola</option>
<option value="AI">Anguilla</option>
<option value="AQ">Antarctica</option>
<option value="AG">Antigua and Barbuda</option>
<option value="AR">Argentina</option>
<option value="AM">Armenia</option>
<option value="AW">Aruba</option>
<option value="AU">Australia</option>
<option value="AT">Austria</option>
<option value="AZ">Azerbaijan</option>
<option value="BS">Bahamas</option>
<option value="BH">Bahrain</option>
<option value="BD">Bangladesh</option>
<option value="BB">Barbados</option>
<option value="BY">Belarus</option>
<option value="BE">Belgium</option>
<option value="BZ">Belize</option>
<option value="BJ">Benin</option>
<option value="BM">Bermuda</option>
<option value="BT">Bhutan</option>
<option value="BO">Bolivia</option>
<option value="BA">Bosnia-Herzegovina</option>
<option value="BW">Botswana</option>
<option value="BV">Bouvet Island</option>
<option value="BR">Brazil</option>
<option value="IO">British Indian Ocean Territory</option>
<option value="BN">Brunei Darussalam</option>
<option value="BG">Bulgaria</option>
<option value="BF">Burkina Faso</option>
<option value="BI">Burundi</option>
<option value="KH">Cambodia</option>
<option value="CM">Cameroon</option>
<option value="CV">Cape Verde</option>
<option value="KY">Cayman Islands</option>
<option value="CF">Central African Republic</option>
<option value="TD">Chad</option>
<option value="CL">Chile</option>
<option value="CN">China</option>
<option value="CX">Christmas Island</option>
<option value="CC">Cocos (Keeling) Islands</option>
<option value="CO">Colombia</option>
<option value="KM">Comoros</option>
<option value="CG">Congo</option>
<option value="CD">Congo (Democratic Republic)</option>
<option value="CK">Cook Islands</option>
<option value="CR">Costa Rica</option>
<option value="HR">Croatia</option>
<option value="CU">Cuba</option>
<option value="CY">Cyprus</option>
<option value="CZ">Czech Republic</option>
<option value="DK">Denmark</option>
<option value="DJ">Djibouti</option>
<option value="DM">Dominica</option>
<option value="DO">Dominican Republic</option>
<option value="TP">East Timor</option>
<option value="EC">Ecuador</option>
<option value="EG">Egypt</option>
<option value="SV">El Salvador</option>
<option value="GQ">Equatorial Guinea</option>
<option value="ER">Eritrea</option>
<option value="EE">Estonia</option>
<option value="ET">Ethiopia</option>
<option value="FK">Falkland Islands</option>
<option value="FO">Faroe Islands</option>
<option value="FJ">Fiji</option>
<option value="FI">Finland</option>
<option value="FR">France</option>
<option value="FX">France (European Territory)</option>
<option value="GF">French Guiana</option>
<option value="TF">French Southern Territories</option>
<option value="GA">Gabon</option>
<option value="GM">Gambia</option>
<option value="GE">Georgia</option>
<option value="DE">Germany</option>
<option value="GH">Ghana</option>
<option value="GI">Gibraltar</option>
<option value="GR">Greece</option>
<option value="GL">Greenland</option>
<option value="GD">Grenada</option>
<option value="GP">Guadeloupe</option>
<option value="GU">Guam</option>
<option value="GT">Guatemala</option>
<option value="GN">Guinea</option>
<option value="GW">Guinea Bissau</option>
<option value="GY">Guyana</option>
<option value="HT">Haiti</option>
<option value="HM">Heard and McDonald Islands</option>
<option value="VA">Holy See (Vatican)</option>
<option value="HN">Honduras</option>
<option value="HK">Hong Kong</option>
<option value="HU">Hungary</option>
<option value="IS">Iceland</option>
<option value="IN">India</option>
<option value="ID">Indonesia</option>
<option value="IR">Iran</option>
<option value="IQ">Iraq</option>
<option value="IE">Ireland</option>
<option value="IL">Israel</option>
<option value="IT">Italy</option>
<option value="CI">Ivory Coast (Cote D'Ivoire)</option>
<option value="JM">Jamaica</option>
<option value="JP">Japan</option>
<option value="JO">Jordan</option>
<option value="KZ">Kazakhstan</option>
<option value="KE">Kenya</option>
<option value="KI">Kiribati</option>
<option value="KW">Kuwait</option>
<option value="KG">Kyrgyzstan</option>
<option value="LA">Laos</option>
<option value="LV">Latvia</option>
<option value="LB">Lebanon</option>
<option value="LS">Lesotho</option>
<option value="LR">Liberia</option>
<option value="LY">Libya</option>
<option value="LI">Liechtenstein</option>
<option value="LT">Lithuania</option>
<option value="LU">Luxembourg</option>
<option value="MO">Macau</option>
<option value="MK">Macedonia</option>
<option value="MG">Madagascar</option>
<option value="MW">Malawi</option>
<option value="MY">Malaysia</option>
<option value="MV">Maldives</option>
<option value="ML">Mali</option>
<option value="MT">Malta</option>
<option value="MH">Marshall Islands</option>
<option value="MQ">Martinique</option>
<option value="MR">Mauritania</option>
<option value="MU">Mauritius</option>
<option value="YT">Mayotte</option>
<option value="MX">Mexico</option>
<option value="FM">Micronesia</option>
<option value="MD">Moldova</option>
<option value="MC">Monaco</option>
<option value="MN">Mongolia</option>
<option value="MS">Montserrat</option>
<option value="MA">Morocco</option>
<option value="MZ">Mozambique</option>
<option value="MM">Myanmar</option>
<option value="NA">Namibia</option>
<option value="NR">Nauru</option>
<option value="NP">Nepal</option>
<option value="NL">Netherlands</option>
<option value="AN">Netherlands Antilles</option>
<option value="NC">New Caledonia</option>
<option value="NZ">New Zealand</option>
<option value="NI">Nicaragua</option>
<option value="NE">Niger</option>
<option value="NG">Nigeria</option>
<option value="NU">Niue</option>
<option value="NF">Norfolk Island</option>
<option value="KP">North Korea</option>
<option value="MP">Northern Mariana Islands</option>
<option value="NO">Norway</option>
<option value="OM">Oman</option>
<option value="PK">Pakistan</option>
<option value="PW">Palau</option>
<option value="PS">Palestinian Territory</option>
<option value="PA">Panama</option>
<option value="PG">Papua New Guinea</option>
<option value="PY">Paraguay</option>
<option value="PE">Peru</option>
<option value="PH">Philippines</option>
<option value="PN">Pitcairn</option>
<option value="PL">Poland</option>
<option value="PF">Polynesia</option>
<option value="PT">Portugal</option>
<option value="PR">Puerto Rico</option>
<option value="QA">Qatar</option>
<option value="RE">Reunion</option>
<option value="RO">Romania</option>
<option value="RU">Russian Federation</option>
<option value="RW">Rwanda</option>
<option value="GS">S. Georgia &amp; S. Sandwich Isls.</option>
<option value="SH">Saint Helena</option>
<option value="KN">Saint Kitts &amp; Nevis Anguilla</option>
<option value="LC">Saint Lucia</option>
<option value="PM">Saint Pierre and Miquelon</option>
<option value="VC">Saint Vincent &amp; Grenadines</option>
<option value="WS">Samoa</option>
<option value="SM">San Marino</option>
<option value="ST">Sao Tome and Principe</option>
<option value="SA">Saudi Arabia</option>
<option value="SN">Senegal</option>
<option value="SC">Seychelles</option>
<option value="SL">Sierra Leone</option>
<option value="SG">Singapore</option>
<option value="SK">Slovakia</option>
<option value="SI">Slovenia</option>
<option value="SB">Solomon Islands</option>
<option value="SO">Somalia</option>
<option value="ZA">South Africa</option>
<option value="KR">South Korea</option>
<option value="ES">Spain</option>
<option value="LK">Sri Lanka</option>
<option value="SD">Sudan</option>
<option value="SR">Suriname</option>
<option value="SZ">Swaziland</option>
<option value="SE">Sweden</option>
<option value="CH">Switzerland</option>
<option value="SY">Syrian Arab Republic</option>
<option value="TW">Taiwan</option>
<option value="TJ">Tajikistan</option>
<option value="TZ">Tanzania</option>
<option value="TH">Thailand</option>
<option value="TG">Togo</option>
<option value="TK">Tokelau</option>
<option value="TO">Tonga</option>
<option value="TT">Trinidad and Tobago</option>
<option value="TN">Tunisia</option>
<option value="TR">Turkey</option>
<option value="TM">Turkmenistan</option>
<option value="TC">Turks and Caicos Islands</option>
<option value="TV">Tuvalu</option>
<option value="UG">Uganda</option>
<option value="UA">Ukraine</option>
<option value="AE">United Arab Emirates</option>
<option value="GB">United Kingdom</option>
<option value="UY">Uruguay</option>
<option value="UM">USA Minor Outlying Islands</option>
<option value="UZ">Uzbekistan</option>
<option value="VU">Vanuatu</option>
<option value="VE">Venezuela</option>
<option value="VN">Vietnam</option>
<option value="VG">Virgin Islands (British)</option>
<option value="VI">Virgin Islands (USA)</option>
<option value="WF">Wallis and Futuna Islands</option>
<option value="EH">Western Sahara</option>
<option value="YE">Yemen</option>
<option value="YU">Yugoslavia</option>
<option value="ZR">Zaire</option>
<option value="ZM">Zambia</option>
<option value="ZW">Zimbabwe</option></select></td>
</tr>

<tr><td><font face="arial"> Primary Telephone </font></td> <td><input type="text" size=2 name="phone1"> - <input type="text" size=10 name="phone2"></td></tr>

<tr><td><font face="arial"> Email Address : </font></td>
<td><input type="text" size=20 name="email"></td>
</tr>


</table>
</p>
<br>
<hr>
<br>

<table>
<tr><td><font face="arial"><b>Your User ID and Password </b> </font> - <font face="arial" size=2> All fields are required </td><tr>
</table>

<p align="center">
<table>
<tr><td><font face="arial">Create an UserID : </font></td>
<td><input type="text" size=20 name="userID"></td>
</tr>

<tr><td><font face="arial"> Password : </font></td>
<td><input type="password" size=20 name="pw"></td>
</tr>

<tr><td><font face="arial"> Confirm Password : </font></td>
<td><input type="password" size=20 name="pw2"></td>
</tr>

<tr><td><font face="arial"> Secret Question : </font></td>
<td><select name="SecretQ">
<option value="0">Pick a suggested question...</option>
<option value="1">What street did you grow up on?</option>
<option value="2">What is your mother's maiden name?</option>
<option value="3">What is the name of your first school?</option>
<option value="4">What is your pet's name?</option>
<option value="5">What is your father's middle name?</option>
<option value="6">What is your school's mascot?</option>
</select>
<br></td></tr>
<tr>
<td></td>
<td>
<font face="arial" size=2> You will be asked for the answer to your secret question if you forget your password. </font>
</td></tr>

<tr><td><font face="arial"> Secret Answer : </font></td>
<td><input type="text" name="SecretA" size=20>
</td></tr>
</table>

<br>

<p align="center">
<input type="submit" value="Register" name="register">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="reset" value="Reset" name="reset">
</p>

</form>

<?php
}
else
{


$fname =$_POST['fname'];
$lname =$_POST['lname'];
$gender =$_POST['gender'];
$bmonth =$_POST['birthmonth'];
$bday =$_POST['birthday'];
$byear =$_POST['birthyear'];
$add1 =$_POST['add1'];
$add2 =$_POST['add2'];
$add3 =$_POST['add3'];
$city =$_POST['city'];
$zcode =$_POST['zcode'];
$country =$_POST['country'];
$phone1 =$_POST['phone1'];
$phone2 =$_POST['phone2'];
$email =$_POST['email'];
$userID =$_POST['userID'];
$pw =$_POST['pw'];


$connection = mysql_connect('localhost','root') or
die ('Unable to open a connection with database server');

mysql_select_db('cus_info') or die ('Unable to select database');

$query = "INSERT INTO cus_info(user_id, user_pw, f_name, l_name, gender, bmonth, bday, byear, add1, add2, add3, city, zcode, country, phone1, phone2, email) VALUES ('$userID', '$pw', '$fname', '$lname', '$gender', '$bmonth', '$bday', '$byear', '$add1', '$add2', '$add3', '$city', '$zcode', '$country', '$phone1', '$phone2', '$email')";

$result = mysql_query($query) or die ("Error in query: $query . " . mysql_error());

echo " User information has been successfully registered !";

echo mysql_affected_rows();

mysql_close($connection);

}

?>

<br>
<br>
<hr>

<p align="center">
<font size=2 face=arial color=8b6969>
Copyright © 2002-2004 <br>
Advance2004 Sdn. Bhd All Rights Reserved.<br>
ThumbDrive Trademark <br>
Registered in Malaysia.<br>
</p>

</body>
</html>

Share this post


Link to post
Share on other sites
Are you getting any type of error??

Ray

Share this post


Link to post
Share on other sites
change

[code]<form action = "<?=$SERVER['PHP_SELF']?>" method="POST">[/code]

to

[code]<form action = "<? echo $_SERVER['PHP_SELF']; ?>" method="POST">[/code]

Share this post


Link to post
Share on other sites
That change doesn't change a thing. When short tags are enabled "<?=" is a short hand for "<? echo".

Ken

Share this post


Link to post
Share on other sites
[!--quoteo(post=370457:date=May 1 2006, 10:22 PM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ May 1 2006, 10:22 PM) [snapback]370457[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Are you getting any type of error??

Ray
[/quote]

hey ray...

thanks for giving me reply...

the page didnt show any error message...but whenever i click submit button...it still displaying the same page .. and all the input didnt go into my database table.. data base table is showed empty set...

i saw my lecturer jz nw..she asked me to seperate the form and the php code .. i have already change it..still it's the same..

i will copy paste the coding again here....

regards..
irene

Share this post


Link to post
Share on other sites
dear all...problem solved.....

thanks a million for ken, ray and radox...

thanks a lot for u guys' help....

i just separate the coding without using <?$_SERVER=['PHP_SELF']?>

thanks for everything... ...

Share this post


Link to post
Share on other sites
ok you could have kept the same code. The problem was you named your submit button register and in your code you were looking for submit. If you change this line:


[code]if(!$_POST['submit'])[/code]

to this
[code]if(!$_POST['register'])[/code]

You will be all set

Ray

Share this post


Link to post
Share on other sites
[!--quoteo(post=370552:date=May 2 2006, 09:17 AM:name=craygo)--][div class=\'quotetop\']QUOTE(craygo @ May 2 2006, 09:17 AM) [snapback]370552[/snapback][/div][div class=\'quotemain\'][!--quotec--]
ok you could have kept the same code. The problem was you named your submit button register and in your code you were looking for submit. If you change this line:
[code]if(!$_POST['submit'])[/code]

to this
[code]if(!$_POST['register'])[/code]

You will be all set

Ray
[/quote]

i ll try it...

thanks a lot...ray..

Share this post


Link to post
Share on other sites

×

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.