SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: PHP Problems

  1. #1
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP Problems

    ok this is what i am working on http://www.nmlco.com/secure/. I am still having trouble printing any of the session data. please if you can help me at all either reply or message me or pm me.

    here is my new index.php

    PHP Code:
    <?
    // INCLUDE SESSION FILE
    require('includes/sessions.php');

    // SET THE CONFIGURATION
    include('includes/config.php');

    ?>

    <html>

    <head>
      <title><? echo $conf['name'],' - ',$app['name']; ?></title>
      <link rel="stylesheet" type="text/css" href="includes/styles/main.css">
    </head>

    <body>
    <?php


    if(isset($step))
    {
      if(
    $step == '1'// Gets from the variable $step the section number
      
    {
        
    $step "1";
      }
      include(
    "includes/part/section".$step.".php"); // Include the file associated with the variable $step
    }
    else
    {
      include(
    "includes/part/section1.php");
    }

    ?>
    </body>

    </html>
    HERE is my sessions.php file
    PHP Code:
            // START THE SESSION
            
    session_start();
            
            
    // SET VARIABLES
            
    extract($_POST);
            foreach(
    $_POST as $k => $v)
                     if (
    $k != 'submit')
            if (!isset(
    $_SESSION[$k])) $_SESSION[$k] = $v
    Here is my section1.php file

    PHP Code:
    if ($step 0) {
        
    $var $step 1;
    } else {    
        
    $step '1';        
        
    $var $step 1;
    }

    echo 
    "<form action=\"?step=$var&sid=$PHPSESSID\" method=\"post\">
     <table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"600\" align=\"center\">
            <tr>
                    <td colspan=\"3\" id=\"header\">SECTION 1 - TYPE OF MORTGAGE AND TERMS OF LOAN</td>
            </tr>
            <tr>
                    <td id=\"field\" width=200 valign=\"middle\">Mortgage Type</td>
                    <td width=5></td>
                    <td id=\"input\">
                    <select name=\"morgage_type\">
                            <option value=\"\">Select A Mortgage Type
                            <option value=\"VA\">VA
                            <option value=\"FHA\">FHA
                            <option value=\"Conventional\">Conventional
                            <option value=\"USDA/Rural Housing Service\">USDA/Rural Housing Service
                            <option value=\"Other\">Other
                    </SELECT>
                    </td>
            </tr>
            <tr>
                    <td id=\"field\" width=200 valign=\"middle\">Loan Amount</td>
                    <td width=5></td>
                    <td id=\"input\"><input type=\"text\" value=\"\" size=\"15\" name=\"loan_amount\"></td>
            </tr>
            <tr>
                    <td id=\"field\" width=200 valign=\"middle\">Loan Term</td>
                    <td width=5></td>
                    <td id=\"input\">
                    <select name=\"loan_term\">
                            <option value=\"\">Select A Loan Term
                            <option value=\"5 Year\">5 Year
                            <option value=\"10 Year\">10 Year
                            <option value=\"15 Year\">15 Year
                            <option value=\"20 Year\">20 Year
                            <option value=\"25 Year\">25 Year
                            <option value=\"30 Year\">30 Year
                    </SELECT></td>
            </tr>
            <tr>
                    <td id=\"field\" width=200 valign=\"middle\">Amortization Type</td>
                    <td width=5></td>
                    <td id=\"input\">
                    <select name=\"amortization_type\">
                            <option value=\"\">Select Amortization Type
                            <option value=\"Fixed Rate\">Fixed Rate
                            <option value=\"GPM\">GPM
                            <option value=\"ARM\">ARM
                            <option value=\"Other\">Other
                    </SELECT>
                    </td>
            </tr>
            <tr>
                    <td id=\"input\" align=\"center\" colspan=\"3\">
                    <input type=\"submit\" value=\"Submit\"></td>
            </tr>
    </table>"


  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1)You need to learn to use braces in your code, and you need to learn proper indenting:
    PHP Code:
    foreach($_POST as $k => $v)
    {
        if (
    $k != 'submit')
        {
            if (!isset(
    $_SESSION[$k])) 
                
    $_SESSION[$k] = $v
        }

    2)You should use php tags, e.g.
    PHP Code:
    <?php

    ?>
    The tags you use are deprecated.

    3)
    I am still having trouble printing any of the session data.
    As far as I can tell, your index.php consists of this:
    PHP Code:
    <?php>
            
    session_start();
            
            
    // SET VARIABLES
            
    extract($_POST);
            foreach(
    $_POST as $k => $v)
                     if (
    $k != 'submit')
            if (!isset(
    $_SESSION[$k])) $_SESSION[$k] = $v
    ?>

    <html>
    ...
    ...
    ...

    <?php

    ?>
    Where are you "printing" any session variables?

    4) This is a php forum, so the assumption is that posts are about "php problems". Try something more descriptive next time, like:

    HELP MEE!!!! HELP ME!!! I CAN'T GET SESSIONS TO WORK!!!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •