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
Solved

php help page goes blank

Posted on 2007-12-01
11
175 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
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to count occurrences of each item in an array.
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 …

856 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