?
Solved

php help page goes blank

Posted on 2007-12-01
11
Medium Priority
?
179 Views
Last Modified: 2013-12-12
I am wondering why this page is comin up blank
Thanks
<?php
       require_once('con_info.php'); 
	session_start();
		
	if (!$_SESSION['user'] || !$_SESSION['pass']) {	
		if(isset($_REQUEST["submit"]))
        {
                // form submitted, do your update statements here...
                // Do your database update statements here
        }
        else 
        {
		
                $query = "SELECT * FROM survey where user='".$_SESSION['user']."'AND pass='".$_SESSION['pass']."'";
                // connect to your database
                
                $result = mysql_query($query);
                
                $row = mysql_fetch_array($result);
                
                //$querycity = "SELECT * FROM school";
                //$resultCity = mysql_query($querycity);
                
                
?>
<form action="<?php echo basename($_SERVER['PHP_SELF']) ; ?>" method="post" >
  <table width="502" border="0">
    
    <tr>
      <td colspan='2'>2. School Address:</td>
      <td><input name="scaddress" type="text" id="scaddress" value="<?php echo $row['scaddress']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>3. School Phone:</td>
      <td><input name="scphone" type="text" id="scphone" value="<?php echo $row['scphone']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>4. School Fax:</td>
      <td><input name="scfax" type="text" id="scfax" value="<?php echo $row['scfax']; ?>" size="31"></td>
    </tr>
    
    <tr>
      <td colspan='3'>
     <input type='submit' name='submit' id='submit' value='Submit' style='height: 40px; width: 200px; color: red; font:bold'></td>
    </tr>
    <tr>
      <td colspan='3'>&nbsp;</td>
    </tr>
  </table>
</form>
 
<?php 
 
        }
		}
?>

Open in new window

0
Comment
Question by:syedasimmeesaq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
11 Comments
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390449
The cause is probably due to one of the following:

if (!$_SESSION['user'] || !$_SESSION['pass'])
one of these session variables are set, thus it doesn't go into the if statement (and you have no else statement)

if(isset($_REQUEST["submit"]))
You have submitted, thus it doesn't go into the else statment for this if claus, so you get a blank page.

To verify this, try the following code and see what prints out:
<?php
       require_once('con_info.php'); 
        session_start();
                
        if (!$_SESSION['user'] || !$_SESSION['pass']) 
        { 
                if(isset($_REQUEST["submit"]))
		        {
		        	echo "You submitted something...";
		                // form submitted, do your update statements here...
		                // Do your database update statements here
		        }
		        else 
		        {
		                
		                $query = "SELECT * FROM survey where user='".$_SESSION['user']."'AND pass='".$_SESSION['pass']."'";
		                // connect to your database
		                
		                $result = mysql_query($query);
		                
		                $row = mysql_fetch_array($result);
		                
		                //$querycity = "SELECT * FROM school";
		                //$resultCity = mysql_query($querycity);
                
                
?>
<form action="<?php echo basename($_SERVER['PHP_SELF']) ; ?>" method="post" >
  <table width="502" border="0">
    
    <tr>
      <td colspan='2'>2. School Address:</td>
      <td><input name="scaddress" type="text" id="scaddress" value="<?php echo $row['scaddress']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>3. School Phone:</td>
      <td><input name="scphone" type="text" id="scphone" value="<?php echo $row['scphone']; ?>" size="31"></td>
    </tr>
    <tr>
      <td colspan='2'>4. School Fax:</td>
      <td><input name="scfax" type="text" id="scfax" value="<?php echo $row['scfax']; ?>" size="31"></td>
    </tr>
    
    <tr>
      <td colspan='3'>
     <input type='submit' name='submit' id='submit' value='Submit' style='height: 40px; width: 200px; color: red; font:bold'></td>
    </tr>
    <tr>
      <td colspan='3'>&nbsp;</td>
    </tr>
  </table>
</form>
 
<?php 
 
		        }
        }
        else 
        {
        	echo "First If statement's ELSE here";
        }
?>

Open in new window

0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390451
Correction on my statement:

if (!$_SESSION['user'] || !$_SESSION['pass'])
one of these session variables are set, thus it doesn't go into the if statement (and you have no else statement)

i was meaning:
if (!$_SESSION['user'] || !$_SESSION['pass'])
BOTH of these session variables are set, thus it doesn't go into the if statement (and you have no else statement)
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390471
yep that was the problem however my textarea is not getting populated from the database... my textfields are ok but textarea doesn't show any data. the textarea fields in data base are longtext 500
would you know what could be the problem
Thanks
0
WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390476
I am using this to populate the textarea
 <textarea name='g2' type='text' id='g2' size='65' value='<?php echo $row['g2']; ?>'></textarea>
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390478
syedasimmeesag,

Correct me if I am wrong but I can't see any text areas in your code which is given?
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390480
change this to:
 <textarea name='g2' type='text' id='g2' size='65'><?php echo $row['g2']; ?></textarea>

All should work.
0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390520
you are absolutely right. That worked. I didn't put the whole code so I don't confuse experts. I have one last question, why this dropdown box doesn't pull any values
<p><select name='f2' id='f2'>
          <option value='ABC '>1. ABC </option>
          <option value='EFG'>2. EFG</option>
          <option selected><?php echo $row['f2']; ?></option>
        </select></p></td>

I am trying to pull the value from field and then giving visitors an option to change it
Thanks
0
 
LVL 21

Accepted Solution

by:
nizsmo earned 2000 total points
ID: 20390526
it works with a test value, so nothing wrong with your SELECT OPTION element, as demonstrated below.
Therefore it must be you $row['f2'] which does not contain anything? Try and echo this out and see if it outputs anything.
<p><select name='f2' id='f2'>
          <option value='ABC '>1. ABC </option>
          <option value='EFG'>2. EFG</option>
          <option selected><?php echo "test"; ?></option>
</select></p></td>

Open in new window

0
 
LVL 9

Author Comment

by:syedasimmeesaq
ID: 20390553
Thank you ..yup there was no value in the field... I will be posting a same question about update in a while. If you get a chance please have a look at it as it is the same coding so it may be eaiser for you to troubleshool. I will post the link here
Thanks a lot.
0
 
LVL 9

Author Closing Comment

by:syedasimmeesaq
ID: 31412173
Excellent ansers...very quick and prompt response
Thank you nizsmo
0
 
LVL 21

Expert Comment

by:nizsmo
ID: 20390556
no problem glad to help :)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question