Jump to content

Hi a bit of PHP help needed.


rofl90

Recommended Posts

OK, so I've coded up this login and I've got a separate section and now I'm designing a website for an artist, and to my knowledge I don't know if It's possible to code a section where my client can browse for a picture and then fill out another form to write a comment, in the backend, and then to display the picture in a specified area in the frontend, could anyone help me out?

Link to comment
Share on other sites

What you'll want to do is store the image path and its related comment in a database. You then simply supply a form for your client to fill in there comment based on the record id.

 

If this goes over your head, you'll probably need to look at some tutorials as this sort of thing is well covered. You might try the link in my signiture.

Link to comment
Share on other sites

I understand it so I just store the image path in MySQL then I pluck the image path into where it should be to display it in PHP, in PHP, and the comment where it should, be..

OK, I understand, also what's wrong with this syntax error line 23, I don't understand it :(

 

<?php

/**
* @Charles Kirk
* @copyright 2007
*/

ob_start();
include("config.php");
if($logged[username] && $logged[level] ==5)
{

if($_GET[user])
{

if (!$_POST[update])
{

$user = mysql_query("SELECT * from users where username = '$_GET[user]'");
$user = mysql_fetch_array($user);
echo("

<div align="center"><form method="POST">
<table width="100%">
<tr>
<td align="right" width="25%">
User Level 
</td>
<td align="left">
<input type="text" size="25" maxlength="25" name="level"
value="$user[level]"></td>
</tr>
<tr>
<td align="right" width="25%">
Location 
</td>
<td align="left">
<input type="text" size="25" maxlength="25" name="locate"
value="$user[location]"></td>
</tr>
<tr>
<td align="right" width="25%">
MSN Messenger 
</td>
<td align="left">
<input size="25" name="msn" value="$user[msn]"></td>
</tr>
<tr>
<td align="right" width="25%">
AOL Messenger</td>
<td align="left">
<input size="25" name="aim"  value="$user[aim]"></td>
</tr>
<tr>
<td align="right" width="25%">
Email Address</td>
<td align="left">
<input size="25"  name="email" value="$user[email]"></td>
</tr>
<tr>
<td align="center">
</td>
<td align="left">
<input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
</div>");

}
else
{
$email = htmlspecialchars($_POST[email]);
$aim = htmlspecialchars($_POST[aim]);
$msn = htmlspecialchars($_POST[msn]);
$locate = htmlspecialchars($_POST[locate]);
$level = htmlspecialchars($_POST[level]);

echo ("$_GET[user]'s profile has been updated.");
$update = mysql_query("Update users set email = '$email',
msn = '$msn', aim = '$aim',
location = '$locate', level = '$level' where username = '$_GET[user]'");

}
}
else
{
$getusers = mysql_query("Select * from users order by username asc");
while($users = mysql_fetch_array($getusers))
{

echo("<a href="admin.php?user=$users[username]">$users[username]</a><br />");

}
}
}
else
{

echo("Sorry, but you are not allowed to view this page!");
}
?>

Link to comment
Share on other sites

escape the " with \

 

look you use this

 

echo("<div align="center"><form method="POST">

should be

echo("<div align=\"center\"><form method=\"POST\">

or

echo    '  <div align="center"><form method="POST">

 

note i dont include your whole script its just the logic i gave you

Link to comment
Share on other sites

Still giving the same syntax error for both I'll give you 5 up and 5 down:

if (!$_POST[update])
{

$user = mysql_query("SELECT * from users where username = '$_GET[user]'");
$user = mysql_fetch_array($user);
echo("

echo    '   <div align="center"><form method="POST">
<table width="100%">
<tr>
<td align="right" width="25%">

or so...

Link to comment
Share on other sites

<?php

/**
* @Charles Kirk
* @copyright 2007
*/

ob_start();
include("config.php");
if($logged[username] && $logged[level] ==5)
{

if($_GET[user])
{

if (!$_POST[update])
{

$user = mysql_query("SELECT * from users where username = '{$_GET['user']}'");
$user = mysql_fetch_array($user);
echo'

<div align="center"><form method="POST">
<table width="100%">
<tr>
<td align="right" width="25%">
User Level 
</td>
<td align="left">
<input type="text" size="25" maxlength="25" name="level"
value="$user[level]"></td>
</tr>
<tr>
<td align="right" width="25%">
Location 
</td>
<td align="left">
<input type="text" size="25" maxlength="25" name="locate"
value="$user[location]"></td>
</tr>
<tr>
<td align="right" width="25%">
MSN Messenger 
</td>
<td align="left">
<input size="25" name="msn" value="$user[msn]"></td>
</tr>
<tr>
<td align="right" width="25%">
AOL Messenger</td>
<td align="left">
<input size="25" name="aim"  value="$user[aim]"></td>
</tr>
<tr>
<td align="right" width="25%">
Email Address</td>
<td align="left">
<input size="25"  name="email" value="$user[email]"></td>
</tr>
<tr>
<td align="center">
</td>
<td align="left">
<input type="submit" name="update" value="Update"></td>
</tr>
</table>
</form>
</div>';

}
else
{
$email = htmlspecialchars($_POST[email]);
$aim = htmlspecialchars($_POST[aim]);
$msn = htmlspecialchars($_POST[msn]);
$locate = htmlspecialchars($_POST[locate]);
$level = htmlspecialchars($_POST[level]);

echo ("{$_GET[user]}'s profile has been updated.");
$update = mysql_query("Update users set email = '$email',
msn = '$msn', aim = '$aim',
location = '$locate', level = '$level' where username = '{$_GET[user]}'");

}
}
else
{
$getusers = mysql_query("Select * from users order by username asc");
while($users = mysql_fetch_array($getusers))
{

echo("<a href="admin.php?user=$users[username]">".$users[username]."</a><br />");

}
}
}
else
{

echo("Sorry, but you are not allowed to view this page!");
}
?>

Link to comment
Share on other sites

This is what I  have so far..

 

<?php

/**
* @Charles Kirk
* @copyright 2007
*/

if ($_REQUEST[completed] == 1) {
       $source = "images";
       move_uploaded_file($_FILES['filename']['tmp_name'],
               "../$source/".$_FILES['filename']['name']);
       if (! eregi ('(gif|jpg|tif|pdf)$',$_FILES['filename']['name'])) {
       $fi = file("../$source/".$_FILES['filename']['name']);
       $fi2 = fopen("../$source/".$_FILES['filename']['name'],"w");
       foreach ($fi as $lne) {
               $n = rtrim ($lne);
               fputs ($fi2,"$n\n");
               }
       }
//
?>
Your file has been uploaded.
<?php } else { ?>
<br><br>
<form enctype=multipart/form-data method=post>
<input type=hidden name=MAX_FILE_SIZE value=150000>
<input type=hidden name=completed value=1>
Choose file to send: <input type=file name=filename> and
<input type=submit name=Submit></form><br>
<?php  } ?>
</body>
</html>

Link to comment
Share on other sites

I want the client to be able to upload the picture which i've done, then at the same time upload the name into mysql to take out and show in a php file, he also needs to be able to choose out of 7 categories, and he needs to be able to create more categories... greedy needy man :(

EDIT the file i posted earlier doesn't work eg it doesn't like add the picture to http://www.******.com/images/

Link to comment
Share on other sites

Okay, you have created the upload script, then:

 

Put in Mysql



$filename=$_FILE['filefield']['name'];

$data="INSERT INTO table (filename) VALUES ('$filename')";
$query=mysql_query($data);

 

Show it in a php file:

 



$data="SELECT * FROM table";
$query=mysql_query($data);

$row=mysql_fetch_assoc($query);

echo "<img src='uploaddirectory/" .$row['filefield']. "'>";

 

Thats All I understood from you..

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.