PHP help

  • kej0283
  • Novice
  • Novice
  • kej0283
  • Posts: 18

Post 3+ Months Ago

<td align="left">'.$row['email']. <a href="mailto:email goes here">email</a>'</td>

I was woudering if you can write something like that...

I want to on screen show a link to the email and then when user click that it goes to out look

However, on the admin side.. I want the admin to able to type in a email and never have to go to the mysql page to do this and it will just create the link for you a the user can just click the link etc..

Or do I not add the email in the database and just write it evertime in HTML???

Also for the admin side.. how do you create an only admin logo so that before you can login you have create the username and password in mysql before the admin can login??


Oh and more question How do you wrte out in php and the database.. where it will show up on scree says for example

where in the database you would have to have say a start time filed and a end time filed

Oct 2, 2005 5:30am-3:00pm.. How do you write show up like that on screen??
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • UPSGuy
  • Lurker ಠ_ಠ
  • Web Master
  • User avatar
  • Posts: 2733
  • Loc: Nashville, TN

Post 3+ Months Ago

For your first portion, you need something like this:

Code: [ Select ]
<td align="left"><a href="mailto:<?= $row['email'];?>">email</a>'</td>


I'm not really sure what you're asking on the rest, but it sort of sounds like you're wanting to build an interface to a mysql database? If that's the case, we have several tutorials here to poke around or Google will return a few thousand recommendations - that has to be one of the most rewritten tutorials out there.
  • kej0283
  • Novice
  • Novice
  • kej0283
  • Posts: 18

Post 3+ Months Ago

I can't figure out why this won't redirect

Here's the link to my problem..

craftofcharismadotcom/login2.php - it wounldn't me send a link.. dot(.)

This is error i get when I type something in and try to redirect

Fatal error: Call to undefined function: escape_data() in /home/content/p/u/a/puacharm/html/login2.php on line 15
PHP Code: [ Select ]
<?php
 
include ("header2.php");
if (isset($_POST['submitted'])) {
 
   require_once ('configlogin.php'); // Connect to the db.
     
   $errors = array(); // Initialize error array.
   
   // Check for an email address.
   if (empty($_POST['email'])) {
      $errors[] = 'You forgot to enter your email address.';
   } else {
      $e = escape_data($_POST['email']);
   }
   
   // Check for a password.
   if (empty($_POST['password'])) {
      $errors[] = 'You forgot to enter your password.';
   } else {
      $p = escape_data($_POST['password']);
   }
   
   if (empty($errors)) { // If everything's OK.
 
      /* Retrieve the user_id and first_name for
      that email/password combination. */
      $query = "SELECT user_id, first_name FROM users WHERE email='$e' AND password=SHA('$p')";    
      $result = @mysql_query ($query); // Run the query.
      $row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable.
 
      if ($row) { // A record was pulled from the database.
           
         // Set the session data & redirect.
         session_name ('YourVisitID');
         session_start();
         $_SESSION['user_id'] = $row[0];
         $_SESSION['first_name'] = $row[1];
         $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
 
         // Redirect the user to the loggedin2.php page.
         // Start defining the URL.
         $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
         // Check for a trailing slash.
         if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
            $url = substr ($url, 0, -1); // Chop off the slash.
         }
         // Add the page.
         $url .= 'loggedin2.php';
         
         header("Location: $url");
         exit(); // Quit the script.
           
      } else { // No record matched the query.
         $errors[] = 'The email address and password entered do not match those on file.'; // Public message.
         $errors[] = mysql_error() . '<br /><br />Query: ' . $query; // Debugging message.
      }
     
   } // End of if (empty($errors)) IF.
     
   mysql_close(); // Close the database connection.
 
} else { // Form has not been submitted.
 
   $errors = NULL;
 
} // End of the main Submit conditional.
 
// Begin the page now.
$page_title = 'Login';
 
 
if (!empty($errors)) { // Print any error messages.
   echo '<h1 id="mainhead">Error!</h1>
   <p class="error">The following error(s) occurred:<br />';
   foreach ($errors as $msg) { // Print each error.
      echo " - $msg<br />\n";
   }
   echo '</p><p>Please try again.</p>';
}
 
// Create the form.
?>
<h2>Login</h2>
<form action="login2.php" method="post">
   <p>Email Address: <input type="text" name="email" size="20" maxlength="40" /> </p>
   <p>Password: <input type="password" name="password" size="20" maxlength="20" /></p>
   <p><input type="submit" name="submit" value="Login" /></p>
   <input type="hidden" name="submitted" value="TRUE" />
</form>
  1. <?php
  2.  
  3. include ("header2.php");
  4. if (isset($_POST['submitted'])) {
  5.  
  6.    require_once ('configlogin.php'); // Connect to the db.
  7.      
  8.    $errors = array(); // Initialize error array.
  9.    
  10.    // Check for an email address.
  11.    if (empty($_POST['email'])) {
  12.       $errors[] = 'You forgot to enter your email address.';
  13.    } else {
  14.       $e = escape_data($_POST['email']);
  15.    }
  16.    
  17.    // Check for a password.
  18.    if (empty($_POST['password'])) {
  19.       $errors[] = 'You forgot to enter your password.';
  20.    } else {
  21.       $p = escape_data($_POST['password']);
  22.    }
  23.    
  24.    if (empty($errors)) { // If everything's OK.
  25.  
  26.       /* Retrieve the user_id and first_name for
  27.       that email/password combination. */
  28.       $query = "SELECT user_id, first_name FROM users WHERE email='$e' AND password=SHA('$p')";    
  29.       $result = @mysql_query ($query); // Run the query.
  30.       $row = mysql_fetch_array ($result, MYSQL_NUM); // Return a record, if applicable.
  31.  
  32.       if ($row) { // A record was pulled from the database.
  33.            
  34.          // Set the session data & redirect.
  35.          session_name ('YourVisitID');
  36.          session_start();
  37.          $_SESSION['user_id'] = $row[0];
  38.          $_SESSION['first_name'] = $row[1];
  39.          $_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
  40.  
  41.          // Redirect the user to the loggedin2.php page.
  42.          // Start defining the URL.
  43.          $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
  44.          // Check for a trailing slash.
  45.          if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) {
  46.             $url = substr ($url, 0, -1); // Chop off the slash.
  47.          }
  48.          // Add the page.
  49.          $url .= 'loggedin2.php';
  50.          
  51.          header("Location: $url");
  52.          exit(); // Quit the script.
  53.            
  54.       } else { // No record matched the query.
  55.          $errors[] = 'The email address and password entered do not match those on file.'; // Public message.
  56.          $errors[] = mysql_error() . '<br /><br />Query: ' . $query; // Debugging message.
  57.       }
  58.      
  59.    } // End of if (empty($errors)) IF.
  60.      
  61.    mysql_close(); // Close the database connection.
  62.  
  63. } else { // Form has not been submitted.
  64.  
  65.    $errors = NULL;
  66.  
  67. } // End of the main Submit conditional.
  68.  
  69. // Begin the page now.
  70. $page_title = 'Login';
  71.  
  72.  
  73. if (!empty($errors)) { // Print any error messages.
  74.    echo '<h1 id="mainhead">Error!</h1>
  75.    <p class="error">The following error(s) occurred:<br />';
  76.    foreach ($errors as $msg) { // Print each error.
  77.       echo " - $msg<br />\n";
  78.    }
  79.    echo '</p><p>Please try again.</p>';
  80. }
  81.  
  82. // Create the form.
  83. ?>
  84. <h2>Login</h2>
  85. <form action="login2.php" method="post">
  86.    <p>Email Address: <input type="text" name="email" size="20" maxlength="40" /> </p>
  87.    <p>Password: <input type="password" name="password" size="20" maxlength="20" /></p>
  88.    <p><input type="submit" name="submit" value="Login" /></p>
  89.    <input type="hidden" name="submitted" value="TRUE" />
  90. </form>
  • kej0283
  • Novice
  • Novice
  • kej0283
  • Posts: 18

Post 3+ Months Ago

rediret to the 'loggedin2.php' page..

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: ScottG, wpas and 87 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.