Jump to content

PaulRyan

Members
  • Posts

    876
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by PaulRyan

  1. Here is something I threw together, give it a try.

     

     

    <?PHP
    
      //### For test purposes
      $email = '123@yahoo.com';
    
      //### Array of endings and url to go to
      $emailArray = array('@yahoo.com' => 'URL 1',
                          '@gmail.com' => 'URL 2'
                         );
                         
      //### Iterate over each of the array elements to find a match for the email                   
      foreach($emailArray AS $ending => $location) {
        if(strstr($email, $ending)) {
          $headerLocation = $location;
          break;
        }
      }
     
      //### If the ending is matched, re-direct to that url
      if(isset($headerLocation)) {
     
        echo 'Re-directing to: '.$headerLocation;  
     
      //### If the ending is not match do something else
      } else {
     
        echo 'Normal form processing';
     
      }
     
    ?>
  2. I would personally go with the database approach.

     

    Set up a database to store user uploads, possible columns:

    1 - id

    2 - uploaded_by

    3 - file_path

    4 - upload_time

     

    Then create the upload form/page, Upload page:

    1 - Create upload form

    2 - On successful upload, add new record to the table

     

    Then on the Index page:

    1 - Retrieve the records from the table and display them on the page.

  3. The errors are self explanatory, the variables and the indexes are undefined.

     

    For index.php

    $username = isset($_SESSION['username']) ? $_SESSION['username'] : FALSE ;
    $password = isset($_SESSION['password']) ? $_SESSION['password'] : FALSE ;
    

    for both login/register, add the following above the switch statement(going on a limb on this one)

    $act = isset($_GET['act']) ? $_GET['act'] : FALSE ;
    

    For information on the above look up Ternary Operators

  4. In future, please use the code tags.

     

    Try this:

    <?PHP
    
      $con = mysql_connect('127.0.0.1', 'root', '');
     
      if(!$con) {
        die('Connection Failed: '.mysql_error());
      } else {
        mysql_select_db('test', $con);
      }
     
      //### Assign get variable, if it exists
      $rowID = isset($_GET['number']) ? (int)$_GET['number'] : FALSE ;
     
      //### If the number doesn't exist, display error
      if(empty($rowID)) {
        echo 'No row selected to edit.';
        exit;
      }
     
      //### Select row from database table
      $dbQuery  = "SELECT * FROM `budget` WHERE `ID` = {$rowID}";
      $dbResult = mysql_query($dbQuery) or die(mysql_error());
     
      //### Check if a row was returned
      if(!mysql_num_rows($dbResult)) {
        echo 'No row was returned.';
        exit;
      } else {
        $row = mysql_fetch_assoc($dbResult);
      }
     
    ?>
    
    <form method="post" action="edit_data.php">
      <input type="hidden" name="ID" value="<?PHP echo $row['ID']; ?>">
     
      <table cellspacing="0" cellpadding="0" border="0">
        <tr>        
          <td> AMOUNT </td>
          <td> <input type="text" name="amount" size="20" value="<?PHP echo $row['AMOUNT']; ?>"> </td>
        </tr>
        <tr>
          <td> PUPOSE </td>
          <td> <input type="text" name="purpose" size="40"  value="<?PHP echo $row['PURPOSE']; ?>"> </td>
        </tr>
        <tr>
          <td> DATE </td>
          <td> <input type="text" name="date" size="40" value="<?PHP echo $row['DATE']; ?>"> </td>
        </tr>
        <tr>        
          <td> NAME </td>
          <td> <input type="text" name="name" size="20" value="<?PHP echo $row['NAME']; ?>"> </td>
        </tr>
        <tr>
          <td align="right"> <input type="submit" name="submit value" value="Edit"> </td>
        </tr>
      </table>
     
    </form>
  5. QuickOldCar, the variable $user_input should be inside of the if statement, otherwise it will display an error. Providing that errors are set to be displayed, which they should be.

    <?PHP
     
      if($_SERVER['REQUEST_METHOD'] == 'POST') {
        $user_input = isset($_POST['user_input']) ? trim($_POST['user_input']) : FALSE ;
     
        if(empty($user_input)) {
          echo 'No user input entered.';
        } else {
          echo 'User Input: '. $user_input;
        }
      }
     
    ?>
    
    <form action="" method="POST">
      <input type="text" name="user_input" size="20">
      <input type="submit" name="press" value="Press da button!">
    </form>
  6. I personally would load the news from the MySQL table into a JS array and then cycle through them 1 by 1.

     

    You could create a scrolling div or just fade the news in and out using jQuery or plain JS.

  7. Always use return. Using echo will echo out the content where ever the function is called, so if you called the function before the header etc, it would display whatever you echo above the header.

     

    Using return, you assign the function call to a variable for use later on in the code.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.