pouncer
Members-
Posts
324 -
Joined
-
Last visited
Never
Everything posted by pouncer
-
php refreshing page after deleting a sql entry
pouncer replied to pouncer's topic in PHP Coding Help
Ok. hmm the line 106 is <td width="50%"><div align="right"><span class="style74"><a href="member.php">Member home</a> | <a href="myprofile.php">My profile</a> | <a href="jkj">My collections</a> | <a href="myprivatemessages.php">My private messages</a> </span></div></td> -
php refreshing page after deleting a sql entry
pouncer replied to pouncer's topic in PHP Coding Help
thanks for the reply jes! I'm getting some errors, i just did this to test [code] <?php if (isset($_POST['Submit_x'])) { $message_id = $_POST['message_id']; header('Location: $PHP_SELF'); } ?> [/code] Warning: Cannot modify header information - headers already sent by (output started at c:\domains\interzurf.nl\wwwroot\socialnetwork\member\myprivatemessages.php:106) in c:\domains\interzurf.nl\wwwroot\socialnetwork\member\myprivatemessages.php on line 169 -
[code] <?php if (isset($_POST['Submit_x'])) { $message_id = $_POST['message_id']; echo "the delete was clicked on messageid: " . $message_id; //delete that message with $message_id - I can do this, no problem //refresh the page so that the table will have 1 less entry - how do i refresh? } ?> [/code]
-
[quote author=jesirose link=topic=123746.msg511914#msg511914 date=1169596809] This is an HTML question, not PHP [code] <td><a href="URLHERE"><img src="<?php echo $image; ?>" alt="Generating image"></a></td> [/code] [/quote] thanks and sorry :p
-
<td><img src="<?php echo $image; ?>" alt="Generating image"></td> can someone show me what to add to this line to make the image a hyperlink?
-
[quote author=kenrbnsn link=topic=123735.msg511901#msg511901 date=1169596268] You only have to check submit_x or submit_y, since if one is set the other will be also. Ken [/quote] Thanks. [code=php:0] if (isset($_POST['Submit_x'])) { $message_id = $_POST['message_id']; echo "the delete was clicked on messageid: " . $message_id; } [/code]
-
ahh i see now :D this worked! [code] if (isset($_POST['Submit_x']) && isset($_POST['Submit_y'])) { $message_id = $_POST['message_id']; echo "the delete was clicked on messageid: " . $message_id; } [/code] :D Thanks guys, and if there is perhaps a better way, please tell me:p
-
[quote author=kenrbnsn link=topic=123735.msg511881#msg511881 date=1169595688] At the start of the script "myprivatemessages.php" put in these lines: [code]<?php echo '<pre>$_GET: ' . print_r($_GET,true) . '</pre>'; echo '<pre>$_POST: ' . print_r($_POST,true) . '</pre>'; ?>[/code] This will dump the values being passed to your script from the form. Ken [/quote] i gt this: $_GET: Array ( ) $_POST: Array ( [message_id] => 14 [Submit_x] => 10 [Submit_y] => 4 )
-
[quote author=jesirose link=topic=123735.msg511877#msg511877 date=1169595625] pouncer, Submit is empty, it has no value. Perhaps add [code]<input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" value="Submit">[/code] [/quote] still no luck :'(
-
just tried that.. [code] <form method ='post' action=\"myprivatemessages.php\" name='record'> <td><input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" ></td> <input type='hidden' name='message_id' value='$message_id'> </form> [/code] but still, when i click the delete icon, it doesnt even echo anything if (isset($_POST['Submit'])) { echo "the delete was clicked!"; }
-
[quote author=kenrbnsn link=topic=123735.msg511855#msg511855 date=1169594803] You're using the POST method, so you should be looking in the $_POST array for the message_id: [code]<?php $message_id = $_POST['message_id']; ?>[/code] Ken [/quote] thanks, didnt work tho all the code is within myprivatemessages.php it doesnt even echo the 'weeeeee'
-
Sorry, i should have pasted more. it is within PHP, it just adds the records to a table with a delete.ico next to each record incase i want to delete the entry [code] <?php $Me = $_SESSION['Username']; $Get_Messages = mysql_query("SELECT count(message_id) FROM private_messages WHERE To_='$Me'"); if (mysql_num_rows($Get_Messages) < 1) echo "You have no private messages.<br>"; else { $Num_Messages = mysql_result($Get_Messages, 0, 'count(message_id)'); echo "You have a total of " . $Num_Messages . " private message(s)<br><br>"; echo "<img src='../index_images/read.gif'>" . " read message " . "<img src='../index_images/unread.gif'>" . " unread message " . "<img src='../index_images/delete.ico'>" . " delete message"; $priv = mysql_query("SELECT * FROM private_messages WHERE To_='$Me'"); echo " <table width=90% cellpadding=0 cellspacing=3 border=0 align=center> <tr> <th></th> <th bgcolor=#E1E4F2>Message</th> <th bgcolor=#E1E4F2>Date sent</th> <th></th> </tr>"; while ($message_info = mysql_fetch_array($priv)) { $message_id = $message_info['message_id']; $message_from = stripslashes($message_info['From_']); $message_subject = stripslashes($message_info['Subject']); $message_datesent = stripslashes($message_info['Date_Sent']); $message_read = stripslashes($message_info['Recipient_Read']); if ($message_read == 1) $image = "../index_images/read.gif"; else $image = "../index_images/unread.gif"; echo " <tr> <td><img src=\"$image\"></td> <td align=left bgcolor=#F5F5FF><a href=\"hghg\">Re: $message_subject</a><br>$message_from</td> <td align=center bgcolor=#F5F5FF>$message_datesent</td> <form method ='post' action='myprivatemessages.php' name='record'> <td><input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" ></td> <input type='hidden' name='message_id' value='$message_id'> </form> </tr>"; } echo "</table>"; } ?> <?php if (isset($_POST['Submit'])) { $message_id = $_GET['message_id']; echo "weeeeee" . $message_id; } ?> [/code] it just doesnt want to echo when i click the delete icon
-
[code] <form method ='post' action='myprivatemessages.php' name='record'> <td><input name='Submit' type=\"image\" src=\"../index_images/delete.ico\" ></td> <input type='hidden' name='message_id' value='$message_id'> </form> [/code] and then below i have: [code] if (isset($_POST['Submit'])) { $message_id = $_GET['message_id']; echo "weeeeee" . $message_id; } [/code] but when i click on the delete icon, it should echo that, but it doesn;t anyone help me out please?
-
thanks guys! it worked fine with .ico :P
-
[code] <form method ='post' action='delete_privatemessage.php' name='record'> <td><img src=\"../index_images/delete.ico\"></td> <input type='hidden' name='message_id' value='$message_id'> </form> [/code] Instead of putting the button there, i put a .ico image there. but how can i make it go to the 'delete_privatemessage.php' page properly because, in 'delete_privatemessage.php' i need to get the message_id and remove that entry!!!
-
just as a quick solution, i tried this: [code] $_accepted_extensions = array('.jpg', '.bmp', '.gif'); $tmp = pathinfo($_FILES['imageupload']['name']); if (!in_array('.' . $tmp['extension'], $_accepted_extensions)) { echo "Wrong file type"; return; } [/code] but it doesnt echo anything, it still attempts to uplaod the file with the wrong file extension
-
Thanks alot guys.
-
[code] if (isset($_POST['Submit'])) { $target_path = "../profile_images/"; $nm = basename($_FILES['imageupload']['name']); $target_path = $target_path . $nm; if(move_uploaded_file($_FILES['imageupload']['tmp_name'], $target_path)) { echo "The file ". $nm . " has been uploaded to your profile."; $user_id = $_SESSION['UserID']; $Image_URL = "thumbnail.php?im=" . "profile_images/" . $nm; $profile = mysql_query("UPDATE user_profile SET Image_URL = '$Image_URL' WHERE user_id = '$user_id' ") or die (mysql_error()); } else echo "There was an error uploading the image, please try again."; } [/code] does this mean i can only upload .jpgs ? how can i make it give an error if i specify a wrong file type to be uploaded
-
[code=php:0] function GetUserNameFromID($id) { $sql = mysql_query("SELECT username FROM users WHERE userid='$id'"); return what??; } [/code] how do i actually return the username
-
I found these great thumbnail script [code=php:0] <?php // useage is thumbnail.php?im=imagename.jpg // set for 120 px thumb Header("Content-type: image/jpeg"); $orig_image = imagecreatefromjpeg($im); list($width, $height, $type, $attr) = getimagesize($im); if ($width > 120) { $ratio = 120 / $width; $newheight = $ratio * $height; } else $newheight = $height; $sm_image = imagecreatetruecolor(120,$newheight) or die ("Cannot Initialize new gd image stream");; Imagecopyresampled($sm_image,$orig_image,0,0,0,0,120,$newheight,imagesx($orig_image),imagesy($orig_image)); imageJPEG($sm_image); imagedestroy($sm_image); imageDestroy($orig_image); ?> [/code] its works great but im not sure which parts to edit to make the thumbnail slightly bigger, and does anyone have a clear understanding off what the code is actually doing?
-
[code=php:0] <?php $file_dir = "c:/domains/interzurf.nl/wwwroot/socialnetworking"; foreach($_FILES as $file_name => $file_array) { echo "path: " . $file_array['tmp_name'] . "<br>\n"; echo "name: " . $file_array['name'] . "<br>\n"; echo "size: " . $file_array['type'] . "<br>\n"; echo "type: " . $file_array['size'] . "<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die("Couldnt copy"); echo "file was moved<br><br>"; } } ?> [/code] And this is the html... [code] <html> <head> <title>A simple file upload form</title> </head> <body> <form action="profile_image_upload.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="200000" /> <p><strong>File to upload:</strong> <input type="file" name="fileupload"></p> <p><input type="submit" value="upload!"></p> </form> </body> </html> [/code] Problem is when i upload i get this: path: C:\PHP4\uploadtemp\php73AE.tmp name: image.JPG size: image/pjpeg type: 129022 Warning: move_uploaded_file(c:/domains/interzurf.nl/wwwroot/socialnetworking/image.JPG) [function.move-uploaded-file]: failed to open stream: No such file or directory in c:\domains\interzurf.nl\wwwroot\socialnetwork\profile_image_upload.php on line 11 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\PHP4\uploadtemp\php73AE.tmp' to 'c:/domains/interzurf.nl/wwwroot/socialnetworking/image.JPG' in c:\domains\interzurf.nl\wwwroot\socialnetwork\profile_image_upload.php on line 11 Couldnt copy Hope someone can help me out please, thanks edit: line 11 is the 'move_uploaded_file' line
-
[quote author=jesirose link=topic=123573.msg510977#msg510977 date=1169509267] try size="30" [/quote] perfect, thanks.
-
<input name="imageupload" type="file" class="style74"> i want to make the box longer. can someone tell me how?
-
i have this code firstly, but would lie to know what parts of it mean: [code=php:0] <html> <head> <title>A simple file upload form</title> </head> <body> <form action="file_uploadTest.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="MAX_FILE_SIZE" value="200000" /> <p><strong>File to upload:</strong> <input type="file" name="fileupload"></p> <p><input type="submit" value="upload!"></p> </form> </body> </html> [/code] <input type="hidden" name="MAX_FILE_SIZE" value="200000" /> 200000 what? and also what this means: enctype="multipart/form-data" the actual php code to upload the file is [code=php:0] $file_dir = "dir.."; foreach($_FILES as $file_name => $file_array) { echo "path: " . $file_array['tmp_name'] . "<br>\n"; echo "name: " . $file_array['name'] . "<br>\n"; echo "size: " . $file_array['type'] . "<br>\n"; echo "type: " . $file_array['size'] . "<br>\n"; if (is_uploaded_file($file_array['tmp_name'])) { move_uploaded_file($file_array['tmp_name'], "$file_dir/$file_array[name]") or die("Couldnt copy"); echo "file was moved<br><br>"; } } [/code] is there an easier way to do this? im not sure what all the file array stuff is for and its hard to understand :s hope someone can make it clear what it means thanks