Jump to content

Recommended Posts

hey guys

not sure how to explain this so I'll show you what I have so far.

I have members.php that contain

[code]
//......
$tmpl->add_template("main");
$a=(isset($_GET['a']) ? $_GET['a'] : 'default');
$uname = $_GET['user'];
    switch($a) {
      case "editprofile":
      $process=$_POST['process'];
        if ($process == "yes") {
        $process_b=$_POST['process_b'];
        $username=$_POST['username'];
          if ($process_b == "yes") {
          $new_email=$_POST['new_email'];
          $new_name=$_POST['new_name'];
            if (strlen($new_uname) < 5 || strlen($new_email) < 6 || strlen($new_name) < 3) {
            $tmpl->add_template("editprofile_tooshort");
            }
            else {
            mysql_query("UPDATE ".$prefix."users SET username='$new_uname',email='$new_email',realname='$new_name' WHERE username='$username'") or die(query_error());
            $tmpl->add_template("editprofile_success");
            }
          }
          else {
          
          }
        }
        else {
        $result=mysql_query("SELECT * FROM ".$prefix."users WHERE username='".$uname."'") or die(query_error());
          $row=mysql_fetch_array($result);
            if ($row['id'] != "") {
            $tmpl->add_template("editprofile_form");
            }
        }      
      break;
      case "viewprofile":
      $tmpl->add_template("viewprofile");
      break;    
    }
//.......
[/code]

so when a person clicks on Edit Profile it takes them to this form (editprofile_form.php)

[code]
<div id="article">
<form action="members.php?a=editprofile" method="post">
<input type="hidden" name="process" value="yes" />
<input type="hidden" name="process_b" value="yes" />
<input type="hidden" name="username" value="<?php echo $username; ?>" />
<table border="0">
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td>Email:</td>
<td><input type="text" name="new_email" value="<?php echo $row['email']; ?>" maxlength="150" /></td>
</tr>
<tr>
<td>First name:</td>
<td><input type="text" name="new_name" value="<?php echo $row['fname']; ?>" maxlength="75" /></td>
</tr>
<tr>
  <td>Last name:</td>
  <td><input type="text" name="new_name2" value="<?php echo $row['lname']; ?>" maxlength="75" /></td>
</tr>
<tr>
//.....
[/code]

my problem is that the input boxes don't show any value..... I know I'm querying the right table and that the rows exist and have info in them so why are the boxes empty...?

any help would be greatly aprecaited

*edit*
if I place echo $row['email']; in members.php it works perfectly so why doesn't it work in the form...?
Link to comment
https://forums.phpfreaks.com/topic/10030-mysql-query-help/
Share on other sites

[!--quoteo(post=375354:date=May 19 2006, 05:13 PM:name=ryanlwh)--][div class=\'quotetop\']QUOTE(ryanlwh @ May 19 2006, 05:13 PM) [snapback]375354[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You have $uname here, which i suspect should be $username.
[code]$result=mysql_query("SELECT * FROM ".$prefix."users WHERE username='".$uname."'")[/code]
[/quote]

$uname is just a variable where the username is stored

$uname = $_GET['user'];

so I don't think that's the problem
Link to comment
https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37286
Share on other sites

What is this doing:

$tmpl->add_template("editprofile_form");

If you're using a template system of some kind, it would depend on how that template system handles PHP code within the templates. Does the add_template() method read in the template file using fread or something similar or does it include() the template file? If it is using something like fread to get the contents of the file, the PHP inside would not be processed.
Link to comment
https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37367
Share on other sites

[!--quoteo(post=375440:date=May 19 2006, 11:30 PM:name=Dave K.)--][div class=\'quotetop\']QUOTE(Dave K. @ May 19 2006, 11:30 PM) [snapback]375440[/snapback][/div][div class=\'quotemain\'][!--quotec--]
What is this doing:

$tmpl->add_template("editprofile_form");

If you're using a template system of some kind, it would depend on how that template system handles PHP code within the templates. Does the add_template() method read in the template file using fread or something similar or does it include() the template file? If it is using something like fread to get the contents of the file, the PHP inside would not be processed.
[/quote]


hey Dave, it simply include() the template file

[code]
session_start();

//
//    Build the template class
//
class Template {
var $errors;
var $cur_page_name;

  //
  //    Create the add_template() function
  //
  function add_template($template_name) {
  $template_name=$template_name.".php";
    //
    //    If the template name is blank...
    //
    if ($template_name == ".php") {
    print("Error loading template.<br />\n");
    $this->errors++;
    }
    else {
      //
      //    The file exists, so output the data
      //
      if (file_exists("template/".$this->cur_page_name."/".$template_name)) {
      include("template/".$this->cur_page_name."/".$template_name);
      }
      //
      //    If it doesn't, don't output the data
      //
      else {
      print("That template doesn't exist.<br />\n");
      $this->errors++;
      }
    }
  }
}[/code]
Link to comment
https://forums.phpfreaks.com/topic/10030-mysql-query-help/#findComment-37415
Share on other sites

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.