I am working on a project and have been doing some research.

One thing I have noticed are tutorials calling for saving the index file in .php.

I tried this and when loading the file, the result is a blank page.

I do not understand why people are suggesting this or, perhaps, I am mising something.

Any suggestions or advice you be much appreciated.


Recommended Answers

Te index file should have a php extension only if you have some PHP code in it. Also your web server should have all the neccessary modules instaled and enabled. Which web server are you using?

Jump to Post

Best way to check if you have php installed is to do



 echo php_info();

Jump to Post

Yes, my index page contains PHP code already (but has a .html extension)

OK, so change it to index.php. It should display html + php script output. If not, check as per iamthwee's suggestion. Mind you there is a small error in his code. Correct code is (see …

Jump to Post

something is wrong at around line 228

if (isset($_POST['type'])) {
    if ($_POST['type'] == "login")

change to

if (isset($_POST['type'])) {
        if ($_POST['type'] == "login") {
        // do something 
        // like displaying your login form
Jump to Post

There are errors in your code above:

Line 199 - missing ; at the end of the line:

echo $state

Line 229 - missing a statement (or at least ;)

if ($_POST['type'] == "login") ;

This is why you get …

Jump to Post

All 18 Replies

Te index file should have a php extension only if you have some PHP code in it. Also your web server should have all the neccessary modules instaled and enabled. Which web server are you using?


Thanks for your reply.

Yes, my index page contains PHP code already (but has a .html extension)

I am using GoDaddy as my hosting service and I believe they are using Apache servers.

Best way to check if you have php installed is to do



 echo php_info();


Yes, my index page contains PHP code already (but has a .html extension)

OK, so change it to index.php. It should display html + php script output. If not, check as per iamthwee's suggestion. Mind you there is a small error in his code. Correct code is (see the manual):


So if you create a index.php script with only above code it should display the information about the PHP installation. If not check out with the hosting provider support.


I have tried changing the index page to .php earlier - I ran it in the browser and it was blank.

On another forum someone else said it was impossible to do this, run a .php in a browser. Now I am very confused.

Thank you for your help!


You can run .php in a browser if the server supports it. If it is on a web hosting server, your provider have to support it (and I guess most do). If you run it localy you have to have a correct environment. In Windows it is XAMP or WAMP, on Linux it is LAMP.

PHP is a server side script. The server (such as Apache) processes it and serves resulting HTML to the browser. But the extension is .php.


I created a new test.php file with the code:




I recieved a huge list as a response containing much information I do not understand at all.

So, I guess .php files do work/display, yet the one I created earlier, index.php, was blank when loaded. I am going to retry that again now.

Cool. PHP works. You do not have to understand all the info for now :-).

Maybe you post the contents of the index.php. You might have some errors in it.

You can temporarily switch error reporting on by including this on top of your PHP code:


What is happening now: I run index.php and it begins to load but then instead loads index.html. Why would this happen?

This is the .php link which then automatically switches to my index holding page, index.html:

It loads index.php in my browser but shows nothing. Can you post the code? Have you tried error reporting?

It loads index.php for me as well, it's blank, which could indicate a syntax error.


I will switch error reporting on now.

Here is the code for index.php which will not display (But instead loads index.html - I have no idea why it would do that)


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


<!--Used to clear form upon submit-->
function clearForms()
  var i;
  for (i = 0; (i < document.forms.length); i++) {

    <title>Sliding Login Panel with jQuery 1.3.2</title>
    <meta name="description" content="Demo of a Sliding Login Panel using jQuery 1.3.2" />
    <meta name="keywords" content=" " />
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />    

    <!-- stylesheets -->
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="css/slide.css" type="text/css" media="screen" />

    <!-- PNG FIX for IE6 -->
    <!-- http://24ways.org/2007/supersleight-transparent-png-in-ie6 -->
    <!--[if lte IE 6]>
        <script type="text/javascript" src="js/pngfix/supersleight-min.js"></script>

    <!-- jQuery Slide -->
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <!-- Sliding effect -->
    <script src="js/slide.js" type="text/javascript"></script>
      function validateEmail(email) { 
        var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(email);

      $(document).ready(function() {


        $('#email_error').html("Please enter a valid email.");


        if ($('#user').val().length<1) {
         if ($('#email').val().length<1 || !validateEmail($('#email').val())) {
         if ($('#pass').val().length<8) {
         if ($('#city').val().length<1) {
         if ($('#pass').val() != $('#confirmpass').val()) {


          var disallowed_characters=/www|http|@|com|\./;

          if (disallowed_characters.test($('#city').val())) {
          if (disallowed_characters.test($('#company').val())) {

          $.getJSON('ajax.php?username='+$('#user').val(), function(data) {
            if (data.error) {
                alert('An error has occured');
            } else {
                if (!data.isUnique) {
                    $('#user_error').html('This username is already taken.');

          $.getJSON('ajax.php?email='+$('#email').val(), function(data) {
            if (data.error) {
                alert('An error has occured');
            } else {
                if (!data.isUnique) {
                    $('#email_error').html('This email is already being used.');

               if ($('#equals_val').val() != (parseInt($('#first_val').val()) + parseInt($('#second_val').val()))) {

              if (!error) { 


    <link rel="icon" href="favicon.ico" type="image/x-icon"/>
        <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>

<!--Country Dropdown-->

<!-- <msdropdown> -->
<link rel="stylesheet" type="text/css" href="css/msdropdown/dd.css" />
<script src="js/msdropdown/jquery.dd.min.js"></script>
<!-- </msdropdown> -->
<link rel="stylesheet" type="text/css" href="css/msdropdown/flags.css" />
.error_message {
  color: #cf1717; 
  font: Arial; 
  font-size: 14px; 
#panel {
    height: auto;


<!--Used to clear form upon submit-->
<body "onUnload="clearForms()">



$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL:" . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL:" . mysql_error());

function NewUser()
    $userName = $_POST['user'];
    $email = $_POST['email'];
    $password =  $_POST['pass'];
    $countries = $_POST['countries'];
    $city =  $_POST['city'];
    $company = $_POST ['company'];
    $state = $_POST ['state'];//Added 11/3/2014

    $query = "INSERT INTO Table4 (userName,email,password,countries,city,company,state) VALUES ('$userName','$email','$password','$countries', '$city','$company','$state')";
    $data = mysql_query ($query)or die(mysql_error());
    echo $state

function SignUp()
    if(!empty($_POST['userName']))   //checking the 'user' name which is from Sign-Up.html, is it empty or have some text
        if ($_POST['equals_val'] != ($_POST['first_val'] + $_POST['second_val'])) {
            echo "CAPTCHA IS NOT CORRECT";
        } else {
            $query = mysql_query("SELECT * FROM WebsiteUsers WHERE userName = '$_POST[user]' AND pass = '$_POST[pass]'") or die(mysql_error());

            if(!$row = mysql_fetch_array($query) or die(mysql_error()))
                echo "SORRY...YOU ARE ALREADY REGISTERED USER...";
if (isset($_POST['type'])) {
    if ($_POST['type'] == "login") 


<!-- Panel -->
<div id="toppanel">
    <div id="panel">
        <div class="content clearfix">
            <div class="left">
                <h1>Welcome to RedLineDown</h1><div style="color:#FFFFFF;">RedLineDown</div>

                <p class="grey">###</p>

            <div class="left">

                <!-- Login Form -->
                <form class="clearfix" action="#" method="post">
                    <h1>Member Login</h1>
                    <input type="hidden" name="type" value="login" />

                    <label class="white" for="log">Username:</label>
                    <input class="field" type="text" name="log" id="log" value="" size="23" />

                    <label class="white" for="pwd">Password:</label>
                    <input class="field" type="password" name="pwd" id="pwd" value="" size="23" />

                    <div class="clear"></div>
                <input type="submit" name="submit-form" value="Login" class="bt_login" />    
            <div class="left right"> 

                <!-- Register Form -->
                <form method="POST"  id="member-signup" action="dbConnect100.php">
                    <h1>Not a member yet? Sign Up!</h1>
                    <input type="hidden" name="type" value="signup" />
                    <!-- Username Field -->              
                    <label type="grey" for="signup">Username:</label>
                    <input type="field" type="text" name="user" id="user" value="" size="23")/><span class='error_message' id='user_error'>Required</span>

<!-- Email Field(s) -->  
<label type="grey" for="email">Email:</label>
<input type="field" type="text" name="email" id="email" value="" size="23" /><span class='error_message' id='email_error'>Please enter a valid email.</span>

<!-- Password Field -->
<label type="grey" for="email">Password:</label>
<input type="password" name="pass" id="pass" value="" size="23" /><span class='error_message' id='pass_error'>Password must be at least 8 characters long.</span>

<!-- Password Field -->
<label type="grey" for="email">Confirm Password:</label>
<input type="password" name="confirmpass" id="confirmpass" size="23" /><span class='error_message' id='confirmpass_error'>Passwords do not match.</span>

<!-- Country Dropdown -->
<label type="grey" for="dropdown">Country:</label>        

<select name="countries" id="countries" style="width:290px;">
 <option value='us' data-title="United States" selected="selected">United States</option>
 <option value='ad' data-title="Andorra">Andorra</option>
 <option value='ae' data-title="United Arab Emirates">United Arab Emirates</option>
 <option value='af' data-title="Afghanistan">Afghanistan</option>
 <option value='ag' data-title="Antigua and Barbuda">Antigua and Barbuda</option>
 <option value='ai' data-title="Anguilla">Anguilla</option>
 <option value='al' data-title="Albania">Albania</option>
 <option value='am' data-title="Armenia">Armenia</option>
 <option value='an' data-title="Netherlands Antilles">Netherlands Antilles</option>
 <option value='ao' data-title="Angola">Angola</option>
 <option value='aq' data-title="Antarctica">Antarctica</option>
 <option value='ar' data-title="Argentina">Argentina</option>
 <option value='as' data-title="American Samoa">American Samoa</option>
 <option value='at' data-title="Austria">Austria</option>
 <option value='au' data-title="Australia">Australia</option>
 <option value='aw' data-title="Aruba">Aruba</option>
 <option value='ax' data-title="Aland Islands">Aland Islands</option>
 <option value='az' data-title="Azerbaijan">Azerbaijan</option>
 <option value='ba' data-title="Bosnia and Herzegovina">Bosnia and Herzegovina</option>
 <option value='bb' data-title="Barbados">Barbados</option>
 <option value='bd' data-title="Bangladesh">Bangladesh</option>
 <option value='be' data-title="Belgium">Belgium</option>
 <option value='bf' data-title="Burkina Faso">Burkina Faso</option>
 <option value='bg' data-title="Bulgaria">Bulgaria</option>
 <option value='bh' data-title="Bahrain">Bahrain</option>
 <option value='bi' data-title="Burundi">Burundi</option>
 <option value='bj' data-title="Benin">Benin</option>
 <option value='bm' data-title="Bermuda">Bermuda</option>
 <option value='bn' data-title="Brunei Darussalam">Brunei Darussalam</option>
 <option value='bo' data-title="Bolivia">Bolivia</option>
 <option value='br' data-title="Brazil">Brazil</option>
 <option value='bs' data-title="Bahamas">Bahamas</option>
 <option value='bt' data-title="Bhutan">Bhutan</option>
 <option value='bv' data-title="Bouvet Island">Bouvet Island</option>
 <option value='bw' data-title="Botswana">Botswana</option>
 <option value='by' data-title="Belarus">Belarus</option>
 <option value='bz' data-title="Belize">Belize</option>
 <option value='ca' data-title="Canada">Canada</option>
 <option value='cc' data-title="Cocos (Keeling) Islands">Cocos (Keeling) Islands</option>
 <option value='cd' data-title="Democratic Republic of the Congo">Democratic Republic of the Congo</option>
 <option value='cf' data-title="Central African Republic">Central African Republic</option>
 <option value='cg' data-title="Congo">Congo</option>
 <option value='ch' data-title="Switzerland">Switzerland</option>
 <option value='ci' data-title="Cote D'Ivoire (Ivory Coast)">Cote D'Ivoire(Ivory Coast)</option>
 <option value='ck' data-title="Cook Islands">Cook Islands</option>
 <option value='cl' data-title="Chile">Chile</option>
 <option value='cm' data-title="Cameroon">Cameroon</option>
 <option value='cn' data-title="China">China</option>
 <option value='co' data-title="Colombia">Colombia</option>
 <option value='cr' data-title="Costa Rica">Costa Rica</option>
 <option value='cs' data-title="Serbia and Montenegro">Serbia and Montenegro</option>
 <option value='cu' data-title="Cuba">Cuba</option>
 <option value='cv' data-title="Cape Verde">Cape Verde</option>
 <option value='cx' data-title="Christmas Island">Christmas Island</option>
 <option value='cy' data-title="Cyprus">Cyprus</option>
 <option value='cz' data-title="Czech Republic">Czech Republic</option>
 <option value='de' data-title="Germany">Germany</option>
 <option value='dj' data-title="Djibouti">Djibouti</option>
 <option value='dk' data-title="Denmark">Denmark</option>
 <option value='dm' data-title="Dominica">Dominica</option>
 <option value='do' data-title="Dominican Republic">Dominican Republic</option>
 <option value='dz' data-title="Algeria">Algeria</option>
 <option value='ec' data-title="Ecuador">Ecuador</option>
 <option value='ee' data-title="Estonia">Estonia</option>
 <option value='eg' data-title="Egypt">Egypt</option>
 <option value='eh' data-title="Western Sahara">Western Sahara</option>
 <option value='er' data-title="Eritrea">Eritrea</option>
 <option value='es' data-title="Spain">Spain</option>
 <option value='et' data-title="Ethiopia">Ethiopia</option>
 <option value='fi' data-title="Finland">Finland</option>
 <option value='fj' data-title="Fiji">Fiji</option>
 <option value='fk' data-title="Falkland Islands (Malvinas)">Falkland Islands (Malvinas)</option>
 <option value='fm' data-title="Federated States of Micronesia">Federated States of Micronesia</option>
 <option value='fo' data-title="Faroe Islands">Faroe Islands</option>
 <option value='fr' data-title="France">France</option>
 <option value='fx' data-title="France, Metropolitan">France, Metropolitan</option>
 <option value='ga' data-title="Gabon">Gabon</option>
 <option value='gb' data-title="Great Britain (UK)">Great Britain (UK)</option>
 <option value='gd' data-title="Grenada">Grenada</option>
 <option value='ge' data-title="Georgia">Georgia</option>
 <option value='gf' data-title="French Guiana">French Guiana</option>
 <option value='gh' data-title="Ghana">Ghana</option>
 <option value='gi' data-title="Gibraltar">Gibraltar</option>
 <option value='gl' data-title="Greenland">Greenland</option>
 <option value='gm' data-title="Gambia">Gambia</option>
 <option value='gn' data-title="Guinea">Guinea</option>
 <option value='gp' data-title="Guadeloupe">Guadeloupe</option>
 <option value='gq' data-title="Equatorial Guinea">Equatorial Guinea</option>
 <option value='gr' data-title="Greece">Greece</option>
 <option value='gs' data-title="S. Georgia and S. Sandwich Islands">S. Georgia and S. Sandwich Islands</option>
 <option value='gt' data-title="Guatemala">Guatemala</option>
 <option value='gu' data-title="Guam">Guam</option>
 <option value='gw' data-title="Guinea-Bissau">Guinea-Bissau</option>
 <option value='gy' data-title="Guyana">Guyana</option>
 <option value='hk' data-title="Hong Kong">Hong Kong</option>
 <option value='hm' data-title="Heard Island and McDonald Islands">Heard Island and McDonald Islands</option>
 <option value='hn' data-title="Honduras">Honduras</option>
 <option value='hr' data-title="Croatia (Hrvatska)">Croatia (Hrvatska)</option>
 <option value='ht' data-title="Haiti">Haiti</option>
 <option value='hu' data-title="Hungary">Hungary</option>
 <option value='id' data-title="Indonesia">Indonesia</option>
 <option value='ie' data-title="Ireland">Ireland</option>
 <option value='il' data-title="Israel">Israel</option>
 <option value='in' data-title="India">India</option>
 <option value='io' data-title="British Indian Ocean Territory">British Indian Ocean Territory</option>
 <option value='iq' data-title="Iraq">Iraq</option>
 <option value='ir' data-title="Iran">Iran</option>
 <option value='is' data-title="Iceland">Iceland</option>
 <option value='it' data-title="Italy">Italy</option>
 <option value='jm' data-title="Jamaica">Jamaica</option>
 <option value='jo' data-title="Jordan">Jordan</option>
 <option value='jp' data-title="Japan">Japan</option>
 <option value='ke' data-title="Kenya">Kenya</option>
 <option value='kg' data-title="Kyrgyzstan">Kyrgyzstan</option>
 <option value='kh' data-title="Cambodia">Cambodia</option>
 <option value='ki' data-title="Kiribati">Kiribati</option>
 <option value='km' data-title="Comoros">Comoros</option>
 <option value='kn' data-title="Saint Kitts and Nevis">Saint Kitts and Nevis</option>
 <option value='kp' data-title="Korea (North)">Korea (North)</option>
 <option value='kr' data-title="Korea (South)">Korea (South)</option>
 <option value='kw' data-title="Kuwait">Kuwait</option>
 <option value='ky' data-title="Cayman Islands">Cayman Islands</option>
 <option value='kz' data-title="Kazakhstan">Kazakhstan</option>
 <option value='la' data-title="Laos">Laos</option>
 <option value='lb' data-title="Lebanon">Lebanon</option>
 <option value='lc' data-title="Saint Lucia">Saint Lucia</option>
 <option value='li' data-title="Liechtenstein">Liechtenstein</option>
 <option value='lk' data-title="Sri Lanka">Sri Lanka</option>
 <option value='lr' data-title="Liberia">Liberia</option>
 <option value='ls' data-title="Lesotho">Lesotho</option>
 <option value='lt' data-title="Lithuania">Lithuania</option>
 <option value='lu' data-title="Luxembourg">Luxembourg</option>
 <option value='lv' data-title="Latvia">Latvia</option>
 <option value='ly' data-title="Libya">Libya</option>
 <option value='ma' data-title="Morocco">Morocco</option>
 <option value='mc' data-title="Monaco">Monaco</option>
 <option value='md' data-title="Moldova">Moldova</option>
 <option value='mg' data-title="Madagascar">Madagascar</option>
 <option value='mh' data-title="Marshall Islands">Marshall Islands</option>
 <option value='mk' data-title="Macedonia">Macedonia</option>
 <option value='ml' data-title="Mali">Mali</option>
 <option value='mm' data-title="Myanmar">Myanmar</option>
 <option value='mn' data-title="Mongolia">Mongolia</option>
 <option value='mo' data-title="Macao">Macao</option>
 <option value='mp' data-title="Northern Mariana Islands">Northern Mariana Islands</option>
 <option value='mq' data-title="Martinique">Martinique</option>
 <option value='mr' data-title="Mauritania">Mauritania</option>
 <option value='ms' data-title="Montserrat">Montserrat</option>
 <option value='mt' data-title="Malta">Malta</option>
 <option value='mu' data-title="Mauritius">Mauritius</option>
 <option value='mv' data-title="Maldives">Maldives</option>
 <option value='mw' data-title="Malawi">Malawi</option>
 <option value='mx' data-title="Mexico">Mexico</option>
 <option value='my' data-title="Malaysia">Malaysia</option>
 <option value='mz' data-title="Mozambique">Mozambique</option>
 <option value='na' data-title="Namibia">Namibia</option>
 <option value='nc' data-title="New Caledonia">New Caledonia</option>
 <option value='ne' data-title="Niger">Niger</option>
 <option value='nf' data-title="Norfolk Island">Norfolk Island</option>
 <option value='ng' data-title="Nigeria">Nigeria</option>
 <option value='ni' data-title="Nicaragua">Nicaragua</option>
 <option value='nl' data-title="Netherlands">Netherlands</option>
 <option value='no' data-title="Norway">Norway</option>
 <option value='np' data-title="Nepal">Nepal</option>
 <option value='nr' data-title="Nauru">Nauru</option>
 <option value='nu' data-title="Niue">Niue</option>
 <option value='nz' data-title="New Zealand (Aotearoa)">New Zealand (Aotearoa)</option>
 <option value='om' data-title="Oman">Oman</option>
 <option value='pa' data-title="Panama">Panama</option>
 <option value='pe' data-title="Peru">Peru</option>
 <option value='pf' data-title="French Polynesia">French Polynesia</option>
 <option value='pg' data-title="Papua New Guinea">Papua New Guinea</option>
 <option value='ph' data-title="Philippines">Philippines</option>
 <option value='pk' data-title="Pakistan">Pakistan</option>
 <option value='pl' data-title="Poland">Poland</option>
 <option value='pm' data-title="Saint Pierre and Miquelon">Saint Pierre and Miquelon</option>
 <option value='pn' data-title="Pitcairn">Pitcairn</option>
 <option value='pr' data-title="Puerto Rico">Puerto Rico</option>
 <option value='ps' data-title="Palestinian Territory">Palestinian Territory</option>
 <option value='pt' data-title="Portugal">Portugal</option>
 <option value='pw' data-title="Palau">Palau</option>
 <option value='py' data-title="Paraguay">Paraguay</option>
 <option value='qa' data-title="Qatar">Qatar</option>
 <option value='re' data-title="Reunion">Reunion</option>
 <option value='ro' data-title="Romania">Romania</option>
 <option value='ru' data-title="Russian Federation">Russian Federation</option>
 <option value='rw' data-title="Rwanda">Rwanda</option>
 <option value='sa' data-title="Saudi Arabia">Saudi Arabia</option>
 <option value='sb' data-title="Solomon Islands">Solomon Islands</option>
 <option value='sc' data-title="Seychelles">Seychelles</option>
 <option value='sd' data-title="Sudan">Sudan</option>
 <option value='se' data-title="Sweden">Sweden</option>
 <option value='sg' data-title="Singapore">Singapore</option>
 <option value='sh' data-title="Saint Helena">Saint Helena</option>
 <option value='si' data-title="Slovenia">Slovenia</option>
 <option value='sj' data-title="Svalbard and Jan Mayen">Svalbard and Jan Mayen</option>
 <option value='sk' data-title="Slovakia">Slovakia</option>
 <option value='sl' data-title="Sierra Leone">Sierra Leone</option>
 <option value='sm' data-title="San Marino">San Marino</option>
 <option value='sn' data-title="Senegal">Senegal</option>
 <option value='so' data-title="Somalia">Somalia</option>
 <option value='sr' data-title="Suriname">Suriname</option>
 <option value='st' data-title="Sao Tome and Principe">Sao Tome and Principe</option>
 <option value='su' data-title="USSR (former)">USSR (former)</option>
 <option value='sv' data-title="El Salvador">El Salvador</option>
 <option value='sy' data-title="Syria">Syria</option>
 <option value='sz' data-title="Swaziland">Swaziland</option>
 <option value='tc' data-title="Turks and Caicos Islands">Turks and Caicos Islands</option>
 <option value='td' data-title="Chad">Chad</option>
 <option value='tf' data-title="French Southern Territories">French Southern Territories</option>
 <option value='tg' data-title="Togo">Togo</option>
 <option value='th' data-title="Thailand">Thailand</option>
 <option value='tj' data-title="Tajikistan">Tajikistan</option>
 <option value='tk' data-title="Tokelau">Tokelau</option>
 <option value='tl' data-title="Timor-Leste">Timor-Leste</option>
 <option value='tm' data-title="Turkmenistan">Turkmenistan</option>
 <option value='tn' data-title="Tunisia">Tunisia</option>
 <option value='to' data-title="Tonga">Tonga</option>
 <option value='tp' data-title="East Timor">East Timor</option>
 <option value='tr' data-title="Turkey">Turkey</option>
 <option value='tt' data-title="Trinidad and Tobago">Trinidad and Tobago</option>
 <option value='tv' data-title="Tuvalu">Tuvalu</option>
 <option value='tw' data-title="Taiwan">Taiwan</option>
 <option value='tz' data-title="Tanzania">Tanzania</option>
 <option value='ua' data-title="Ukraine">Ukraine</option>
 <option value='ug' data-title="Uganda">Uganda</option>
 <option value='uk' data-title="United Kingdom">United Kingdom</option>
 <option value='um' data-title="United States Minor Outlying Islands">United States Minor Outlying Islands</option>
 <option value='uy' data-title="Uruguay">Uruguay</option>
 <option value='uz' data-title="Uzbekistan">Uzbekistan</option>
 <option value='va' data-title="Vatican City State (Holy See)">Vatican City State(Holy See)</option>
 <option value='vc' data-title="Saint Vincent and the Grenadines">Saint Vincent and the Grenadines</option>
 <option value='ve' data-title="Venezuela">Venezuela</option>
 <option value='vg' data-title="Virgin Islands (British)">Virgin Islands (British)</option>
 <option value='vi' data-title="Virgin Islands (U.S.)">Virgin Islands (U.S.)</option>
 <option value='vn' data-title="Viet Nam">Viet Nam</option>
 <option value='vu' data-title="Vanuatu">Vanuatu</option>
 <option value='wf' data-title="Wallis and Futuna">Wallis and Futuna</option>
 <option value='ws' data-title="Samoa">Samoa</option>
 <option value='ye' data-title="Yemen">Yemen</option>
 <option value='yt' data-title="Mayotte">Mayotte</option>
 <option value='yu' data-title="Yugoslavia (former)">Yugoslavia (former)</option>
 <option value='za' data-title="South Africa">South Africa</option>
 <option value='zm' data-title="Zambia">Zambia</option>
 <option value='zr' data-title="Zaire (former)">Zaire (former)</option>
 <option value='zw' data-title="Zimbabwe">Zimbabwe</option>

<!-- City Field -->  
<label type="grey" for="email">City:</label>
<input type="field" type="text" name="city" id="city" size="23" />

<!-- State Field --> 
<select name="state" id="state"> 
<option value="--">--</option>
<option value="AK">AK</option>
<option value="AL">AL</option>
<option value="AR">AR</option>
<option value="AZ">AZ</option>
<option value="CA">CA</option>
<option value="CO">CO</option>
<option value="CT">CT</option>
<option value="DC">DC</option>
<option value="DE">DE</option>
<option value="FL">FL</option>
<option value="GA">GA</option>
<option value="HI">HI</option>
<option value="IA">IA</option>
<option value="ID">ID</option>
<option value="IL">IL</option>
<option value="IN">IN</option>
<option value="KS">KS</option>
<option value="KY">KY</option>
<option value="LA">LA</option>
<option value="MA">MA</option>
<option value="MD">MD</option>
<option value="ME">ME</option>
<option value="MI">MI</option>
<option value="MN">MN</option>
<option value="MO">MO</option>
<option value="MS">MS</option>
<option value="MT">MT</option>
<option value="NC">NC</option>
<option value="ND">ND</option>
<option value="NE">NE</option>
<option value="NH">NH</option>
<option value="NJ">NJ</option>
<option value="NM">NM</option>
<option value="NV">NV</option>
<option value="NY">NY</option>
<option value="OH">OH</option>
<option value="OK">OK</option>
<option value="OR">OR</option>
<option value="PA">PA</option>
<option value="RI">RI</option>
<option value="SC">SC</option>
<option value="SD">SD</option>
<option value="TN">TN</option>
<option value="TX">TX</option>
<option value="UT">UT</option>
<option value="VA">VA</option>
<option value="VT">VT</option>
<option value="WA">WA</option>
<option value="WI">WI</option>
<option value="WV">WV</option>
<option value="WY">WY</option>

<span class='error_message' id='city_error'>Please enter a valid city.</span>

<!-- Company Field -->
<label class="white" for="email">Company:</label>
<input class="field" type="text" name="company" id="company" size="23" />
<span class='error_message' id='company_error'>Please enter a valid company name.</span>

<!--Mona Captcha-->

<label class="white" for="captcha">Are you human:</label><br>
<input class="field" type="text" name="first_val" id="first_val" style="width: 30px;" size="3" disabled/> + &nbsp;
<input class="field" type="text" name="second_val" id="second_val" style="width: 30px;" size="3" disabled/> = &nbsp;
<input class="field" type="text" name="equals_val" id="equals_val" style="width: 30px;" size="3" /><br>
<span class='error_message' id='captcha_error'>Captcha is not correct.</span>
<input type="submit" name="submit-form2" value="Register" class="bt_register" />
<img src="loading.gif" id="loadingGif">  
<!-- Captcha End-->


</div> <!-- /login -->    

    <!-- The tab on top -->  
    <div class="tab">
        <ul class="login">
            <li class="left">&nbsp;</li>
            <li>Hello Guest!</li>
            <li class="sep">|</li>
            <li id="toggle">
                <a id="open" class="open" href="#">Log In | Register</a>
                <a id="close" style="display: none;" class="close" href="#">Close Panel</a>           
            <li class="right">&nbsp;</li>
    </div> <!-- / top -->

</div> <!--panel -->

    <div id="container">
        <div id="content" style="padding-top:100px;">

        </div><!-- / content -->      
    </div><!-- / container -->


I inserted




And ran it - Nothing displayed. The page jumped automatically to index.html.

Your database login and password are showing
Change them now!!

Maybe your hosting provider does not allow displaying of errors. Check in web hosting control panel if there is any php or apache error logging.

There is quite a lot of code :-). Have you checked the database is set up correctly or Captcha is correctly used?

It would be good idea to get some code to external files (like Pphp functions, database connection, country selection element etc) which are then just included. It would make code much clearer.

In order you find the cause of the error you should do some simple debugging. I usually put a die statement on various places in PHP code and check if it shows up. Like you could add this on line 180:


and see if DB name gets displayed. If yes you can carry on between lines 181 and 182 with:

die("Connection: " . print_r($con, 1));


I will have to carry on tomorrow since it is almost nidnight here :-)

Part of the reason I am attempting the .php conversion is in order to use include files- I started that this morning and it did not work.

I am sorry for the lengthy and sloppy code - I am in the process of cleaning it up.

Thanks, broj1 :)

something is wrong at around line 228

if (isset($_POST['type'])) {
    if ($_POST['type'] == "login")

change to

if (isset($_POST['type'])) {
        if ($_POST['type'] == "login") {
        // do something 
        // like displaying your login form

There are errors in your code above:

Line 199 - missing ; at the end of the line:

echo $state

Line 229 - missing a statement (or at least ;)

if ($_POST['type'] == "login") ;

This is why you get nothing shown. Errors were proably logged into some error log on the server.

You can also comment out lines 176 to 182 to eliminate possible database connection errors since you do not do any database interaction in the script anyway.

commented: I was just about to lose hope and complain that nobody found it. Thank you for keeping me sane. +5
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.