Jump to content

White_Lily

Members
  • Posts

    531
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by White_Lily

  1. okay i did what you all said.

     

    i recieved 2 errors regarding the file uploading:

     

    Warning: move_uploaded_file(images/uploads/Sunset.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/sites/janedealsart.co.uk/public_html/inc/register-process.php on line 51

     

    Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phprN1MTY' to 'images/uploads/Sunset.jpg' in /home/sites/janedealsart.co.uk/public_html/inc/register-process.php on line 51

  2. Hi,

     

    I am trying to create a registration script that when the user registers and tries to upload an avatar, the image itself is placed in the specified directory, and the file name (with extension) is in the database.

     

    So far I have managed to get it to put the file name (with extension) in the database, but the script fails because there is a problem when the script tries to put the actual image file in the directory.

     

    I was hoping this forum could give some advice/guidance as to how I correct this issue?

     

    I will place the code below:

     

    <?php
    
    include '../cms/inc/conf.php';
    include '../cms/inc/connect.php';
    $page = "Register Result";
    
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    	<title><?php echo $GLOBALS["siteName"]." - ".$page; ?></title>
    	<link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['siteUrl'] ?>/css/design.css">
    </head>
    <body>
    	<div class="wrapper">
    		<div class="header">
    			<img src="<?php echo $GLOBALS["siteUrl"] ?>/images/logo.png" />
    		</div>
    		<div class="content">
    			<div class="left_content">
    				<div class="navigation">
    					<?php
    
    						include 'inc/navigation_include.php';
    
    					?>
    				</div>
    			</div>
    			<div class="middle">
    				<?php
    
    					//This is the directory where images will be saved 
    					 $target = "images/uploads/"; 
    					 $target = $target . basename( $_FILES['photo']['name']);
    
    					$name		= $_POST['name'];
    					$email		= $_POST['email'];
    					$gender		= $_POST['gender'];
    					$country	= $_POST['country'];
    					$user		= $_POST['username'];
    					$pass		= $_POST['password'];
    					$pic=($_FILES['photo']['name']); 
    
    					$sql = "INSERT INTO users (name, email, gender, country, username, password, avatar) VALUES ('$name', '$email', '$gender', '$country', '$user', '$pass', '$pic')";
    					$res = mysql_query($sql);
    
    					if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
    					{
    						echo '<h3>Registration Success</h3>';
    						echo '<p>Thank you for registering.</p>';
    						echo '<a href="../login.php">Login</a>';
    					}
    					else
    					{
    						echo '<h3>Registration Failed</h3>';
    						echo '<p><h1>Oh dear...</h1> it seems there is a problem with the processing script. Please contact the webmaster via the contact form.</p>'.mysql_error();
    						echo '<a href="../register.php">Go Back</a>';
    					}
    
    				?>
    			</div>
    		</div>
    		<div class="clear"></div>
    		<div class="footer">
    			<div class="link-push">
    				<div class="footer-navigation">
    					<?php/*
    
    						$sql = "SELECT * FROM pages";
    						$result = mysql_query($sql);
    						if($result)
    						{
    							echo "  |  ";
    							while ($db_field = mysql_fetch_assoc($result))
    							{
    								echo ("<a href='".$GLOBALS['siteUrl'].'/'.$db_field['page_filename']."'>" . $db_field['page_name'] . "</a>");
    								echo "  |  ";
    							}
    						}
    						else
    						{
    							echo "<p>No pages found.</p>";
    						}
    						mysql_close($con);*/
    
    					?>
    				</div>
    			</div>
    			<div class="copy">
    				<?php echo $GLOBALS["copy"]; ?>
    			</div>
    			<div class="creator">
    				Site created by: <?php echo $GLOBALS["creator"]; ?>
    			</div>
    		</div>
    	</div>
    </body>
    </html>

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