got blank page

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
thania
Forum Newbie
Posts: 11
Joined: Sun Mar 12, 2006 9:19 pm

got blank page

Post by thania »

I got only a blank page when i finish submitting inputs from the html form that i have created. The link that is shown at my browser however is referring to the php file that i have created which is linked with the html file for the input from user namely register.php. The input from user is actually to be inserted in the table "account" which i created in "myfyp" database using PHPMyAdmin. When i checked the database through PHPMyAdmin interface as well as through the command prompt screen, the inputs i just entered in the form are not inserted into the database.

Is dat mean I have connection problem to the database or there is something else?? However, I did not receive any error message that told me any connection problem or any other error appears.

This is the PHP codes namely register.php that I use:

Code: Select all

<?php
include ("connect.php"); 
if (!isset($_POST['Proceed'])) {
submitData();
}

function submitData(){
$name = $_POST['requiredname'];
$studID = $_POST['requiredstudentID'];
$pword = $_POST['pw1'];
$programme = $_POST['requiredprogramme'];
$yearsem = $_POST['requiredyearsem'];
$gender = $_POST['gender'];


mysql_select_db($database) or die($errCon . mysql_error()); 

//Insert input into database

mysql_query("INSERT INTO $table
    (requiredname, requiredstudentID, pw1, requiredprogramme, requiredyearsem,  gender) 

    VALUES('$name', '$studID','$pword','$programme', '$yearsem', ' $gender') ") 

    or die($errCon . mysql_error()); 
	echo "Data Inserted!"; 
	}
?>

and this is the connection file which i use namely connect.php:

Code: Select all

<?php
//<!-- DATABASE CONNECTION INFO---->
$errCon = "<br> Contact your webmaster. <br>";
$hostname="localhost"; 
$mysql_login="root"; 
$mysql_password=""; 
$database="myfyp";
$table= "account";
//&dbtype="MySQL"; 


// connect to the database server  
    mysql_connect($hostname, $mysql_login, $mysql_password) 
    or die($errCon . mysql_error()); 
   

// select a database  
	mysql_select_db($database) or die($errCon . mysql_error()); 

?>

and the html file that i use for the form is register.html:

Code: Select all

<title>Account Registration</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body background="utplogo.jpg">

<h1> Account Registration</h1>
<p>Please fill in the information to register for your account:</p>
<form name= "Proceed" method = "post" action = "register.php">

 <p><label>Name: 
 	<input name = "requiredname" type = "text" size = "40" />
 </label></p>

 <p><label>Student ID
 	<input name = "requiredstudentID" type = "int" size = "15"> 
 </label></p>
 
 <p><label>Password :
	<input name = "pw1" type = "password" size = "15"> 
</label></p>
 
 

<p><label>Programme: 	<select name= "requiredprogramme" >
				<option> Please select one </option>
				<option>Mechanical Engineering</option>
				<option>Electrical & Electronic Engineering</option>
				<option>  Chemical Engineering</option>
				<option>  Civil Engineering</option>
				<option>  Information Technology</option>
				<option>  Information System</option>
				</select>
				</label></p>
 
 <p><label>Year / Semester:  	<select name= "requiredyearsem" >
				<option> Please select one </option>
				<option>Foundation Year / 1st Sem</option>
				<option>Foundation Year / 2nd Sem</option>
				<option>  Year 2 / Sem 1</option>
				<option>  Year 2 / Sem 2</option>
				<option>  Year 3 / Sem 1</option>
				<option>  Year 3 / Sem 2</option>
				<option>  Year 4 / Sem 1</option>
				<option>  Year 4 / Sem 2</option>
				<option>  Year 5 / Sem 1</option>
				<option>  Year 5 / Sem 2 </option>
				</select>
				</label></p>

<p><label> Gender:
		<input type = "radio" name = " gender" CHECKED/> Male 
		<input type = "radio" name = " gender" />Female 
		</label>
  </p>
			

		<br><br>
  <p> 
    <input type = "submit" name = "Proceed" value = "Proceed" style = "height:35px; width: 120px"/>
  
    <input type = "reset" name = "Reset" value = "Reset" style = "height:35px; width: 120px"/>
  </p>



</form>
</body>
</html>


I really hope someone can help me with this problem coz I continually received the blank page even though i have tried to do some appropriate changes.
Thank You very much.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

please run this code and post the output

Code: Select all

<?php

$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n" : "\n");

$ec = array(
   'E_STRICT' => 2048,
   'E_ALL' => 2047,
   'E_USER_NOTICE' => 1024,
   'E_USER_WARNING' => 512,
   'E_USER_ERROR' => 256,
   'E_COMPILE_WARNING' => 128,
   'E_COMPILE_ERROR' => 64,
   'E_CORE_WARNING' => 32,
   'E_CORE_ERROR' => 16,
   'E_NOTICE' => 8,
   'E_PARSE' => 4,
   'E_WARNING' => 2,
   'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
   if (($t & $v) == $v)
   {
      $e[] = $n;
      $t ^= $v;
   }
}
$er = $er . ' (' . implode(' | ', $e) . ')';

echo 'PHP Version: ' . $ve . $eol;
echo 'PHP OS: ' . $os . $eol;
echo 'Error Reporting: ' . $er . $eol;
echo 'Register Globals: ' . $rg . $eol;
echo 'Short Tags: ' . $so . $eol;
echo 'Display Errors: ' . $de . $eol;

?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you're missing a match to the last closing brace register.php. I'd guess you forgot to add an if()
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

feyd wrote:you're missing a match to the last closing brace register.php. I'd guess you forgot to add an if()
Isn't the last closing brace matching with the function opening brace?

Edit | There are no parse errors in the code, but your logic is off.

Change

Code: Select all

if (!isset($_POST['Proceed'])) {
submitData();
}
to

Code: Select all

if (isset($_POST['Proceed'])) {
submitData();
}
Last edited by John Cartwright on Sun Mar 26, 2006 2:58 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hmm didn't see that there. Ignore me. :)
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

feyd wrote:hmm didn't see that there. Ignore me. :)
Whoa.. Feyd made a boo-boo. Thats one for the record books. :wink:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

the function isn't being called, by the way. !isset() will likely return false when the submission is made, however relying on the submit button to be present in the submission isn't the best of things to do (because some browser don't send it in certain conditions)
thania
Forum Newbie
Posts: 11
Joined: Sun Mar 12, 2006 9:19 pm

Post by thania »

Thank you for the respond =)

i have tried to do the change as shown which i have change the:

Code: Select all

if (!isset($_POST['Proceed'])) { 
submitData(); 
}
TO:

Code: Select all

if (isset($_POST['Proceed'])) { 
submitData(); 
}

and there is an error message appers which is:

Code: Select all

Notice: Undefined variable: database in c:\program files\easyphp1-7\www\register.php on line 18

Notice: Undefined variable: errCon in c:\program files\easyphp1-7\www\register.php on line 18
Aucune base n'a été sélectionnée
therefore, i have changed my codes a little bit in order to define the variables that have been mentioned in the error messages like this:

Code: Select all

<?php
include ("connect.php"); 

if (isset($_POST['Proceed'])) {
submitData();
}

function submitData(){
	global $database; 
  	global $table;
	global $errCon;

mysql_select_db($database) or die($errCon . mysql_error()); 
	
$name = $_POST['requiredname'];
$studID = $_POST['requiredstudentID'];
$pword = $_POST['pw1'];
$programme = $_POST['requiredprogramme'];
$yearsem = $_POST['requiredyearsem'];
$gender = $_POST['gender'];


//Insert input into database

mysql_query("INSERT INTO $table
    (requiredname, requiredstudentID, pw1, requiredprogramme, requiredyearsem,  gender) 

    VALUES('$name', '$studID','$pword','$programme', '$yearsem', ' $gender') ") 

    or die($errCon . mysql_error()); 
	echo "Data Inserted!"; 
	}
?>
After the changes, there is a message appears which is:

Code: Select all

Contact your webmaster. 
Champ 'requiredname' inconnu dans field list
this means that the connection cannot be made, doesnt it??

So, how can i settle down this problem and i wonder why do i need to define the variables as stated again because i already include the "connect.php" in this php file which the variables are already defined. i hope somebody can help me..

Thank you very much..
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post by jrd »

i'm still learning. hope i'm not wrong.

Code: Select all

mysql_query("INSERT INTO '$table'
Post Reply