Jump to content

Recommended Posts

ok the personal detail page reads of the database to fill in the input fields, it finds the database using the common file config.php but it is having trouble reading the database or somthing because the input fields are all messed up

 

here is my new page http://lamezz.com/login/members/profile/edit_profile.php?change=personalDetail

 

here is my old page http://lamezz.com/login/members/profile.php

 

use Username: test and Password: test

 

here is my new script

 

elseif ($getlink == "personalDetail") { //personal details changing
print<<<pd
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
      <input type="text" name="name1" value="<?php
include "../../../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo "$qry[name1]"; 
   } 
?>" />
</p><p>Second Name: <br />
    <input type="text" name="name2" value="<?php
include "../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo "$qry[name2]"; 
   } 
?>" />
</p><p>Email Address: <br />
    <input type="text" name="email" value="<?php
include "../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) {
      echo "$qry[email]"; 
   } 
?>" />
</p><p>Your website (URL):<br /> 
      <input type="text" name="website" value="<?php
include "../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) {
      echo "$qry[website]"; 
   } 
?>" />
</p>
    <p>
      <input type="submit" name="Submit" value="Submit" />
</p></center>
</form>
pd;

 

Please Help, Thanks

Link to comment
https://forums.phpfreaks.com/topic/66573-a-mix-of-html-php-mysql-help/
Share on other sites

Well you have opening PHP tags inside your HEREDOC syntax.

What you've written is pretty confusing. I think you need to clean it up, I personally never use HEREDOC.

 

Just change it to:

elseif ($getlink == "personalDetail") { //personal details changing
?>
  <u><b>Your Personal Details</b></u><br />

 

And then at the bottom remove:

pd;

 

No need for it here.

.. Why'd you make it in the first place? So you can BF things for fun?

 

BF? ...???

 

Anyways yeah you shouldnt do things like this

 

print <<<HERE

 

while ($....)

bla bla

 

HERE;

 

make sure the HERE; is fully tabbed to the left

 

HERE; --right

  HERE; ---wrong

 

 

and theres other things to this...im lazy right now

here is my whole script, when I do what you told me to I get a error on line 123, which does not exist

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="../../../style/default.css"/>
<?php
include ("../../../style/include/title.php");
?>
</head>

<body>


 <div class="logo"><?php
include ("../../../style/include/header.php");
?></div>


    
     

       <div class="spacer"></div>

<?php
include ("../../../style/include/logged_menu_member.php");
?>

<div class="box">
<center><font size="3">
<?php
//$username = $_COOKIE['loggedin'];
//if (!isset($_COOKIE['loggedin'])) die("You are not logged in, <a href=../login.php>click here</a> to login.");
//echo "<b>$username</b>'s Profile";
?>
</font></center></div>

<div class="box"><font size="3">
<?php
$getlink = $_GET["change"];


if ($getlink == "requestUsername") { //request username change
echo "cody sucks";
}
elseif ($getlink == "personalDetail") { //personal details changing
print<<<pd
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
      <input type="text" name="name1" value="<?php
include "../../../../../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo "$qry[name1]"; 
   } 
?>" />
</p><p>Second Name: <br />
    <input type="text" name="name2" value="<?php
include "../../../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo "$qry[name2]"; 
   } 
?>" />
</p><p>Email Address: <br />
    <input type="text" name="email" value="<?php
include "../../../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) {
      echo "$qry[email]"; 
   } 
?>" />
</p><p>Your website (URL):<br /> 
      <input type="text" name="website" value="<?php
include "../../../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) {
      echo "$qry[website]"; 
   } 
?>" />
</p>
    <p>
      <input type="submit" name="Submit" value="Submit" />
</p></center>
</form>
pd;
}
elseif ($getlink == "password") { //password changing here
print<<<pw
<form action="update.php" method="post" ><p><u><b>Change your password</b></u><br /></p>
  
    <center><p> Old Password:<br />
    <input type="password" name="oldpass" />
<br />
    <br />
New Password: <br />
<input type="password" name="newpass" />
<br />  
<br />
  
  </p>    <p>
      <input type="submit" name="Submit" value="Submit" />
</p></center>
pw;
}
else {
echo "PENIS FOR NOW";
}
?>
</font></div>
<?php
include ("../../../style/include/footer.php");
?>
</body>
</html>

I am lost in what you mean

 

and no I do not go around BF things for fun. I have never hacked and never will.

 

 

ok....  ...  anyways first dont do this print<<<pd

 

do this

 

print <<<PD

 

space between the print and the <<< and use all caps for "pd" (PD)

I am not familiar with printing html inside of php blocks, but one thing I know doesn't make sence is that you open a php block inside of a php block. For Example:

<?php
$getlink = $_GET["change"];


if ($getlink == "requestUsername") { //request username change
echo "cody sucks";
}
elseif ($getlink == "personalDetail") { //personal details changing
print<<<pd
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
      <input type="text" name="name1" value="<?php

 

There is no closing of php, maybe this is because of the print method you are using, but it makes no sence to me. The error you are getting is something like "unexpected $end," right? This is because it has a open { somewhere without a }, usually. I would look through and try to find it, but I can't figure out your weird printing method. I would suggest changing your method to something more solid.

 

For example, this:

<?php
$getlink = $_GET["change"];


if ($getlink == "requestUsername") { //request username change
echo "cody sucks";
}
elseif ($getlink == "personalDetail") { //personal details changing
print<<<pd
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
      <input type="text" name="name1" value="<?php
include "../../../../../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo "$qry[name1]"; 
   } 
?>

 

can be done like this:

<?php
$getlink = $_GET["change"];
if ($getlink == "requestUsername") { //request username change
echo "cody sucks";
}
elseif ($getlink == "personalDetail") { //personal details changing
?>
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
<?php
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 
$qry = mysql_fetch_array($result)
echo "<input type=\"text\" name=\"name1\" value=\"" . $qry['name1'] . " />";
?>

 

I don't want to tell you how to write your code, but it would be a lot easier to find errors if it was a little simpler.

I am not familiar with printing html inside of php blocks, but one thing I know doesn't make sence is that you open a php block inside of a php block. For Example:

<?php
$getlink = $_GET["change"];


if ($getlink == "requestUsername") { //request username change
echo "cody sucks";
}
elseif ($getlink == "personalDetail") { //personal details changing
print<<<pd
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
      <input type="text" name="name1" value="<?php

 

There is no closing of php, maybe this is because of the print method you are using, but it makes no sence to me. The error you are getting is something like "unexpected $end," right? This is because it has a open { somewhere without a }, usually. I would look through and try to find it, but I can't figure out your weird printing method. I would suggest changing your method to something more solid.

 

For example, this:

<?php
$getlink = $_GET["change"];


if ($getlink == "requestUsername") { //request username change
echo "cody sucks";
}
elseif ($getlink == "personalDetail") { //personal details changing
print<<<pd
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
      <input type="text" name="name1" value="<?php
include "../../../../../config.php";
mysql_connect($server, $db_user, $db_pass) or die (mysql_error()); 
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 

   while ($qry = mysql_fetch_array($result)) { 
      echo "$qry[name1]"; 
   } 
?>

 

can be done like this:

<?php
$getlink = $_GET["change"];
if ($getlink == "requestUsername") { //request username change
echo "cody sucks";
}
elseif ($getlink == "personalDetail") { //personal details changing
?>
  <u><b>Your Personal Details</b></u><br />

      <center><p>First Name: <br />
<?php
$result = mysql_db_query($database, "select * from $table WHERE username = '$username'") or die (mysql_error()); 
$qry = mysql_fetch_array($result)
echo "<input type=\"text\" name=\"name1\" value=\"" . $qry['name1'] . " />";
?>

 

I don't want to tell you how to write your code, but it would be a lot easier to find errors if it was a little simpler.

 

put all printable data in variable form before printing it for HTML

 

like:

 

<?php

 

$display = "Hello, I'm trying to figure this out.";

 

?>

 

<html>

<head>

          <title>The Page</title>

</head>

<body>

          <h3>The Page</h3>

<p><?php print "$display"; ?></p>

 

</body>

</html>

 

 

gives it a cleaner look

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.