Jump to content

Recommended Posts

ok so what I need to do is when a user does not fill in a form, it can make it so it put something else in with out them knowing. So if on a custom user link it would be www.whatever.com/theirusername, it will put in www.whatever.com/myusername, because they didnt fill in the user name in their profile.

 

This is some of my code;

 

In their profile:

 

$req_user_info = $database->getUserInfo($req_user);
....
....
/* GDI Username */
echo "<b>GDI Username:</b> ".$req_user_info['gdi_username']."<br>";

 

 

In their profile editor:

 

<td>GDI Username:</td>
      <td><input type="text" name="gdi_username" maxlength="50" value="
<?
if($form->value("gdi_username") == ""){
   echo $session->userinfo['gdi_username'];
}else{
   echo $form->value("gdi_username");
}
?>">      </td>
      <td><? echo $form->error("gdi_username"); ?></td>
      </tr>

 

In the database file:

 

function getUserInfo($username){
      $q = "SELECT * FROM ".TBL_USERS." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      /* Error occurred, return given name by default */
      if(!$result || (mysql_numrows($result) < 1)){
         return NULL;
      }
      /* Return result array */
      $dbarray = mysql_fetch_array($result);
      return $dbarray;
   }

 

If you need more code i can give it just ask!

 

Thanks for any help!

Link to comment
https://forums.phpfreaks.com/topic/85754-if-statment-with-mysql/
Share on other sites

here is my whole form!

 

<?
include("include/session.php");
?>

<html>
<title>Green Ways - Edit</title>
<style type="text/css">
<!--
body {
background-image: url();
background-color: #d4d4d4;
margin-left: 30px;
margin-right: 30px;
}
.style5 {color: #990000}
-->
</style><body>


<div style="padding-left:15">
  <?
/**
* User has submitted form without errors and user's
* account has been edited successfully.
*/
if(isset($_SESSION['useredit'])){
   unset($_SESSION['useredit']);
   
   echo "<h1>User Account Edit Success!</h1>";
   echo "<p><b>$session->username</b>, your account has been successfully updated. "
       ."<a href=\"member_area.php\">Main</a>.</p>";
}
else{
?>
    
  <?
/**
* If user is not logged in, then do not display anything.
* If user is logged in, then display the form to edit
* account information, with the current email address
* already in the field.
*/
if($session->logged_in){
?>
    
</div>
<h1 align="left"><span class="style5">User Account Edit : <? echo $session->username; ?></span></h1>

<div style="padding-left:15">
  <?
if($form->num_errors > 0){
   echo "<td><font size=\"2\" color=\"#ff0000\">".$form->num_errors." error(s) found</font></td>";
}
?>
</div>
<form action="process.php" method="POST">
  
  <div style="padding-left:15">
    <table align="left" border="0" cellspacing="0" cellpadding="3">
      <tr>
        <td>Current Password:</td>
      <td><input type="password" name="curpass" maxlength="30" value="
<?echo $form->value("curpass"); ?>"></td>
      <td><? echo $form->error("curpass"); ?></td>
      </tr>
      <tr>
        <td>New Password:</td>
      <td><input type="password" name="newpass" maxlength="30" value="
<? echo $form->value("newpass"); ?>"></td>
      <td><? echo $form->error("newpass"); ?></td>
      </tr>
      <tr>
        <td>Email:</td>
      <td><input type="text" name="email" maxlength="50" value="
<?
if($form->value("email") == ""){
   echo $session->userinfo['email'];
}else{
   echo $form->value("email");
}
?>">      </td>
      <td><? echo $form->error("email"); ?></td>
      </tr>
        
      <tr>
        <td>First Name:</td>
      <td><input type="text" name="first_name" maxlength="50" value="
<?
if($form->value("first_name") == ""){
   echo $session->userinfo['first_name'];
}else{
   echo $form->value("first_name");
}
?>">      </td>
      <td><? echo $form->error("first_name"); ?></td>
      </tr>
        
      <tr>
        <td>Last Name:</td>
      <td><input type="text" name="last_name" maxlength="50" value="
<?
if($form->value("last_name") == ""){
   echo $session->userinfo['last_name'];
}else{
   echo $form->value("last_name");
}
?>">      </td>
      <td><? echo $form->error("last_name"); ?></td>
      </tr>
        
      <tr>
        <td>Shaklee ID:</td>
      <td><input type="text" name="shaklee_id" maxlength="50" value="
<?
if($form->value("shaklee_id") == ""){
   echo $session->userinfo['shaklee_id'];
}else{
   echo $form->value("shaklee_id");
}
?>">      </td>
      <td><? echo $form->error("shaklee_id"); ?></td>
      </tr>
        
        <tr>
        <td><p>Shaklee Website:</p>
          <p>Example: http://www.shaklee.net/YourUserName</p></td>
      <td><input type="text" name="shaklee_website" maxlength="50" value="
<?
if($form->value("shaklee_website") == ""){
   echo $session->userinfo['shaklee_website'];
}else{
   echo $form->value("shaklee_website");
}
?>">      </td>
      <td><? echo $form->error("shaklee_website"); ?></td>
      </tr>
        
      <tr>
        <td>Phone Number:</td>
      <td><input type="text" name="phone_number" maxlength="50" value="
<?
if($form->value("phone_number") == ""){
   echo $session->userinfo['phone_number'];
}else{
   echo $form->value("phone_number");
}
?>">      </td>
      <td><? echo $form->error("phone_number"); ?></td>
      </tr>
        
        <td>GDI Username:</td>
      <td><input type="text" name="gdi_username" maxlength="50" value="
<?
if($form->value("gdi_username") == ""){
   echo $session->userinfo['gdi_username'];
}else{
   echo $form->value("gdi_username");
}
?>">      </td>
      <td><? echo $form->error("gdi_username"); ?></td>
      </tr>
        
      <tr>
        <td><h1 class="style5">Response Magic</h1></td>
      </tr>
               
      <tr>
        <td>User Name:</td>
      <td><input type="text" name="rm_user_name" maxlength="50" value="
<?
if($form->value("rm_user_name") == ""){
   echo $session->userinfo['rm_user_name'];
}else{
   echo $form->value("rm_user_name");
}
?>">      </td>
      <td><? echo $form->error("rm_user_name"); ?></td>
      </tr>
        
      <tr>
        <td>Intro Request List Number:</td>
      <td><input type="text" name="rm_list_number_1" maxlength="50" value="
<?
if($form->value("rm_list_number_1") == ""){
   echo $session->userinfo['rm_list_number_1'];
}else{
   echo $form->value("rm_list_number_1");
}
?>">      </td>
      <td><? echo $form->error("rm_list_number_1"); ?></td>
      </tr>
        
      <tr>
        <td>Urgent Request List Number:</td>
      <td><input type="text" name="rm_list_number_2" maxlength="50" value="
<?
if($form->value("rm_list_number_2") == ""){
   echo $session->userinfo['rm_list_number_2'];
}else{
   echo $form->value("rm_list_number_2");
}
?>">      </td>
      <td><? echo $form->error("rm_list_number_2"); ?></td>
      </tr>
        
      <tr><td colspan="2" align="right"><input type="hidden" name="subedit" value="1">
      <input type="submit" value="Edit Account"></td></tr>
      <tr>
        <td colspan="2" align="right"><?
}
}

/* Link back to main */
echo "<br>Back To "?>[<a href="member_area.php">Main</a>]<br>

</td>
      </tr>
      <tr><td colspan="2" align="left"></td></tr>
    </table>
  </div>
</form>


<div align="left"></div>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.