Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:22:57+00:00 2026-05-26T16:22:57+00:00

Here’s the code: <?php // For use in creating individual page $tpl_file = submission.php;

  • 0

Here’s the code:

<?php
// For use in creating individual page
$tpl_file = "submission.php";
$tpl_path = "templates/";
$submissions_path = "submissions/";



// For use in querying submitter name

$username = $_GET['username'];
session_start();
$_SESSION['username'] = $username; 

//Database Information

$dbhost = "";
$dbname = "";
$dbuser = "";
$dbpass = "";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());


$name = $_POST['name'];
$filename = $_POST['filename'];   
$submitter = $username;
list($width, $height) = getimagesize("$filename");
$type = exif_imagetype($_POST['filename']);

$checkuser = mysql_query("SELECT filename FROM images WHERE filename='$filename'");

$filename_exist = mysql_num_rows($checkuser);

if($filename_exist > 0){
    echo "I'm sorry but this image has already been submitted. Please feel free to try another.";
    unset($filename);
    include 'upload.php';
    exit();
}


if (exif_imagetype($_POST['filename']) == IMAGETYPE_GIF) {
    echo "Sorry, but we can't accept GIFs. Please feel free to try uploading another.";
    unset($filename);
    include 'upload.php';
    exit();
}



$query = "INSERT INTO images (name, filename, submitter, width, height, type)
VALUES('$name', '$filename', '$submitter', '$width', '$height', $type)";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "Thanks for your submission!<br/> Upload another <a href='/~lyons/upload.php'>here</a>!";

$tpl = file_get_contents($tpl_path.$tpl_file);
$php_file_name = $name.".php";

$fh = fopen($submissions_path.$php_file_name, "w");
fwrite($fh, $tpl);
fclose($fp); 
?>

When a user submits a picture, it is supposed to automatically create a page based on a template. Here’s the code for the template:

<html>
<title><?php echo $name; ?></title>
<head>
</head>

<body>
<h1><?php echo $name ?></h1>
Posted by: <?php echo $username ?>
<br/>
<img src="<?php echo $filename ?>"/>

</body>
</html>

As you might have already guessed, I want it to put in values for name, username, and filename that were derived in the first script where they submit the picture. However, it seems they don’t carry over. The page is created, but where ever it’s supposed to echo the values for the variables, it is blank. How can I include the values for those variables that I want to use in the created page?

Thanks in advance to whoever can help me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:22:57+00:00Added an answer on May 26, 2026 at 4:22 pm

    I would suggest using a string like %name%, %username% etc. to mark placeholders for variables.

    Then, before writing to the file, try something like this:

    $tpl = preg_replace("(%([a-z_][a-z0-9_]*)%)ie",'$$1',$tpl);
    

    This will find, for example, %filename% and replace it with the contents of the variable $filename.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here a simple question : What do you think of code which use try
Here is my code: <?php $variable1 = 00001; $variable2 = (sprintf('%04d', $variable1 + 1));
Here my code: $(document).ready(function() { $('#mid_select').live('click', function(e){ $('#middle').load( $(this).attr('href') + ' #middle'); var page
Here is my code, which takes two version identifiers in the form 1, 5,
Here is the code I'm using http://jsbin.com/evike5/edit When the jQuery UI dialog is fired
here is the site : http://www.notrepanorama.com at the bottom left, i use a jquery
Here's some of my production code (I had to force line breaks): task =
Here is a great article about GC may occur at unexpected point of code
Here is my javascript code for a cursor focus function to go to username
Here is what I want to do. Use this HTML line and have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.