Jump to content

not updating text


Ninjakreborn

Recommended Posts

The code does everything it's suppose to but one thing.  It takes the template page, and put's it int eh right directory as index.php, but it's blank it's not
1. Copying the info from the specified template page,
2. Updating the content??
[code]<?php
session_start();
?>
<!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" />
<title>Thank You</title>
</head>
<body>
<?php
if ($_SESSION['controller'] == true) {
mysql_connect("localhost", "#####", "#####");
mysql_select_db("hasbadse_hbservice");
// create user account.
$errorhandler = "";
$insert = "INSERT INTO userinfo SET username = '$_SESSION[username]', password = '$_SESSION[password]', email = '$_SESSION[email]', subdomainname = '$_SESSION[subdomain]';";
mysql_query($insert);
$select = "SELECT * FROM userinfo WHERE username = '$_SESSION[username]';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) { // retrieve userid with user account.
$id = $row['id'];
} // end getting userid.


$header = $_SESSION['header'];
$text = $_SESSION['text'];
$insertcms = "INSERT INTO usercms (header, text, userid) VALUES ('$header', '$text', '$id');";
if (!mysql_query($insertcms)) {
$errorhandler .= "There was a problem inserting the Content Management Information.<br />";
$errorhandler .= "Please contact support about this problem.<br />";
}
// VERY IMPORTANT, everything below is used for directory creation.
$var = preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', '"&#".ord($0).";"', $_SESSION['subdomain']);
$dir = "userpages/$var";
mkdir("$dir", 0700);
if (!mkdir) {
$errorhandler .= "unable to create the directory. Please contact support or try again.<br />";
}

$infile = fopen($_SESSION['template'], "r"); // as readonly
while (!feof($infile)) {
$buffer = fread($infile, filesize($_SESSION['template']));
}
fclose($infile);
$buffer = str_replace("$id", $id, $buffer);
// here I can do all my changes to the buffer variable(which contains the file information)
$outfile = fopen("userpages/{$var}/index.php", "w"); // open writeable
fwrite($outfile, $buffer);
fclose ($outfile);

// VERY IMPORTANT, everything above here is used for directory creation.
$insertdn = "INSERT INTO subdomain (path, subdomainname, userid) VALUES ('$dir', '$_SESSION[subdomain]', '$id');";
if (!mysql_query($insertdn)) {
$errorhandler .= "There was a problem, please contact support immediately.<br />";
}
// start check for error handler
if ($errorhandler != "") {
echo "<span style=\"color:red;\">";
echo $errorhandler;
echo "</span>";
}
if ($errorhandler == "") {
?>
<h4>Thank You</h4>
<p>Thank you for your purchase, you can go over to the administration page, and login there.</p>
<a href="/useradmin.php" title="User Admin">User Admin</a>
<?php
}
}else {
echo "You have to go through the entire signup process, before coming to this page, in order <br />";
echo "for your account to be able to be created.<br />";
}
?>
</body>
</html>[/code]
Link to comment
Share on other sites

Everything on the other pages are the same, I redid the stuff on the thankyou page, and there I used a function I found on php.net
Now I have a question.

Here is my new altered code.

[code]<?php
session_start();
function read_file($file)
{
  if(!function_exists("file_get_contents"))return file_get_contents($file);
  $ifile = fopen($file,"r");
  $contents = false;
  if($ifile) while (!feof($ifile)) $contents .= fgets($ifile);
  fclose($ifile);
  return $contents;
}
?>
<!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" />
<title>Thank You</title>
</head>
<body>
<?php
if ($_SESSION['controller'] == true) {
mysql_connect("localhost", "#####", "######");
mysql_select_db("hasbadse_hbservice");
// create user account.
$errorhandler = "";
$insert = "INSERT INTO userinfo SET username = '$_SESSION[username]', password = '$_SESSION[password]', email = '$_SESSION[email]', subdomainname = '$_SESSION[subdomain]';";
mysql_query($insert);
$select = "SELECT * FROM userinfo WHERE username = '$_SESSION[username]';";
$query = mysql_query($select);
if ($row = mysql_fetch_array($query)) { // retrieve userid with user account.
$id = $row['id'];
} // end getting userid.


$header = $_SESSION['header'];
$text = $_SESSION['text'];
$insertcms = "INSERT INTO usercms (header, text, userid) VALUES ('$header', '$text', '$id');";
if (!mysql_query($insertcms)) {
$errorhandler .= "There was a problem inserting the Content Management Information.<br />";
$errorhandler .= "Please contact support about this problem.<br />";
}
// VERY IMPORTANT, everything below is used for directory creation.
$var = preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', '"&#".ord($0).";"', $_SESSION['subdomain']);
$dir = "userpages/$var";
mkdir("$dir", 0700);
if (!mkdir) {
$errorhandler .= "unable to create the directory. Please contact support or try again.<br />";
}

$buffer = read_file($_SESSION['template']);
$buffer = str_replace("$id", $id, $buffer);
// here I can do all my changes to the buffer variable(which contains the file information)
$outfile = fopen("userpages/{$var}/index.php", "w"); // open writeable
fwrite($outfile, $buffer);
fclose ($outfile);

// VERY IMPORTANT, everything above here is used for directory creation.
$insertdn = "INSERT INTO subdomain (path, subdomainname, userid) VALUES ('$dir', '$_SESSION[subdomain]', '$id');";
if (!mysql_query($insertdn)) {
$errorhandler .= "There was a problem, please contact support immediately.<br />";
}
// start check for error handler
if ($errorhandler != "") {
echo "<span style=\"color:red;\">";
echo $errorhandler;
echo "</span>";
}
if ($errorhandler == "") {
?>
<h4>Thank You</h4>
<p>Thank you for your purchase, you can go over to the administration page, and login there.</p>
<a href="/useradmin.php" title="User Admin">User Admin</a>
<?php
}
}else {
echo "You have to go through the entire signup process, before coming to this page, in order <br />";
echo "for your account to be able to be created.<br />";
}
?>
</body>
</html>
[/code]

Ok everything here now works but one thing, at first a lot was wrong with it, but now it's moving it to the directory, properly copying the file contents as needed.  Everything is so far working, but the string replace isn't doing what it's suppose it.  It's suppose to find the occurence of $id
and change $id to the number of the user id, so it can find those entries in the database.
Link to comment
Share on other sites

It didn't work, I changed the test within the template pages to hold instead of id, and I am trying to get it to take the value of id, and insert it where hold is on hte template page, but it's not working.
I am also sure my id variable has the right contents, I don't get why it's not working, any advice.
Link to comment
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.