Solved

php help page goes blank

Posted on 2007-12-01
11
168 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
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…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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 …

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now