
netpumber
Members-
Posts
107 -
Joined
-
Last visited
Everything posted by netpumber
-
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Here is the source code of the form : <br> <table align="center"><td> <form method="post" name="edit_misc" action="editm.php" > <font face="Lucida Console, Courier New, Fixed" size=2 color="#FFF380" >$title :</font> <br> <input style="background:#B0D2D7" type="text" name="title" size="38" value="test"> <br><br> <font face="Lucida Console, Courier New, Fixed" size=2 color="#FFF380">$text:</font> <br> <textarea style="background:#B0D2D7" rows="10" name="entry" cols="48" >testaaa</textarea> <br> <p align="left"><INPUT type="submit" name="edit_misc" value="Save"></p> <input type="hidden" name="id" value="13"> </form> </td> </table> Question 1 : how i will put htmlentities() in textarea ? Question 2 : What exactly you mean ? [x] <?php session_start(); if ($_SESSION['authorized'] != true) { header("Location: login_form.php"); exit; } die(); <---I add this line in editm.php ?> And here is the access log I hope so ... I can't imagine what the hell is happening...:S Thanks anyway...my friend.. -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Lets make them clearly... File edmp.php [means edit main page] It has two forms : 1st Form for editing a table called site_entries here is the code : <?php if(isset($_GET['action']) && $_GET['action']=="edit"){ $q = mysql_query("SELECT title,entry FROM site_entries WHERE id='".mysql_real_escape_string($_GET['id'])."'"); $row = mysql_fetch_array($q); print " <br> <table align=\"center\"><td> <form method=\"post\" name=\"edit_projects\" action=\"editp.php\" > <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\" >\$title :</font> <br> <input style=\"background:#B0D2D7\" type=\"text\" name=\"title\" size=\"38\" value=\"".htmlentities($row['title'])."\"> <br><br> <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\">\$text:</font> <br> <textarea style=\"background:#B0D2D7\" rows=\"10\" name=\"entry\" cols=\"48\" >{$row['entry']}</textarea> <br> <p align=\"left\"><INPUT type=\"submit\" name=\"edit_projects\" value=\"Save\"></p> <input type=\"hidden\" name=\"id\" value=\"".$_GET['id']."\"> </form> </td> </table> "; } ?> As you can see action=\"editp.php\" Here is the code for editp.php: <?php session_start(); if ($_SESSION['authorized'] != true) { header("Location: login_form.php"); exit; } ?> <?php // [start] Save changes for projects ini_set ('display_errors',1); error_reporting (E_ALL); if (isset ($_POST['edit_projects'])){ if ($dbc = @mysql_connect('localhost','user','p@ss')) { if (!@mysql_select_db ('web_site')) { die('<p> Could not select the database brcause:<b>'. mysql_error() .'</b></p>'); } }else{ die('<p>Could not connect to MYSQL because:<b>' . mysql_error() . '</b></p>'); } $query = "UPDATE site_entries SET title='{$_POST['title']}',entry='{$_POST['entry']}' WHERE id={$_POST['id']}"; if (@mysql_query ($query)){ echo "<meta http-equiv='refresh' content='0;URL=edmp.php'>"; }else{ print"<p>Could not add the entry because:<b>" .mysql_error() . "</b>. The query was $query.</p>"; } mysql_close(); } ?> ^ This one works FINE !!! Ok now... the other one form of the edmp.php is for editing a table called misc_entries and here is the code: <?php if(isset($_GET['actionm']) && $_GET['actionm']=="edit"){ $qm = mysql_query("SELECT title,entry FROM misc_entries WHERE id='".mysql_real_escape_string($_GET['id'])."'"); $row = mysql_fetch_array($qm); print " <table align=\"center\"><td> <form method=\"post\" action=\"editm.php\" > <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\" >\$title :</font> <br> <input style=\"background:#B0D2D7\" type=\"text\" name=\"title\" size=\"38\" value=\"".htmlentities($row['title'])."\"> <br><br> <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\">\$text:</font> <br> <textarea style=\"background:#B0D2D7\" rows=\"10\" name=\"entry\" cols=\"48\" >{$row['entry']}</textarea> <br> <p align=\"left\"><INPUT type=\"submit\" name=\"edit_misc\" value=\"Save\"></p> <input type=\"hidden\" name=\"id\" value=\"".$_GET['id']."\"> </form> </td> </table> "; } ?> As you can see action=\"editm.php\" > . The editm.php code is here : <?php session_start(); if ($_SESSION['authorized'] != true) { header("Location: login_form.php"); exit; } ?> <?php // [start] Save changes for projects ini_set ('display_errors',1); error_reporting (E_ALL); if (isset ($_POST['edit_misc'])){ if ($dbc = @mysql_connect('localhost','user','p@ss')) { if (!@mysql_select_db ('web_site')) { die('<p> Could not select the database brcause:<b>'. mysql_error() .'</b></p>'); } }else{ die('<p>Could not connect to MYSQL because:<b>' . mysql_error() . '</b></p>'); } $query = "UPDATE misc_entries SET title='".mysql_real_escape_string($_POST['title'])."',entry='".mysql_real_escape_string($_POST['entry'])."' WHERE id={$_POST['id']}"; echo $query; if (@mysql_query ($query)){ echo "<meta http-equiv='refresh' content='0;URL=edmp.php'>"; }else{ print"<p>Could not add the entry because:<b>" .mysql_error() . "</b>. The query was $query.</p>"; } mysql_close(); } ?> ^ This one doesn't work... I understood that when i press tha Save button the editm.php doesn't executed and the link became edmp.php?title=test&entry=test+test2&edit_misc=Save&id=13 When i press the button Save from the first form all works GREAT . The editp.php script executed. Thats all my friend... -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
So look. In the page edmp.php i have two forms that you can edit two different tables. 1st edit_projects form and 2nd misc_projects form. For the first form this code works perfectly. I mean that you can edit the table. The problem is in the second form that doesn't execute the script in the action= and i don't know why... I can't imagine anything. I thought that occurs because there are two form in the same page but i don't know any more... i try to change these two forms and nothing happens... Have you ever had a problem like this ? -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
hmm i ll try to recode it... -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
I understand that when i press the save button it doesnt execute the editm.php script...Something is wrong in form maybe.. Also the link become like this : .php?title=test&entry=test+a+b+c&edit_misc=Save&id=13 -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
So look at this. i have this code for editing the registers : <?php if(isset($_GET['action1']) && $_GET['action1']=="edit"){ $q = mysql_query("SELECT title,entry FROM misc_entries WHERE id='".mysql_real_escape_string($_GET['id'])."'"); $row = mysql_fetch_array($q); print " <br> <table align=\"center\"><td> <form method=\"post\" name=\"edit_misc\" action=\"editm.php\" > <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\" >\$title :</font> <br> <input style=\"background:#B0D2D7\" type=\"text\" name=\"title\" size=\"38\" value=\"".htmlentities($row['title'])."\"> <br><br> <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\">\$text:</font> <br> <textarea style=\"background:#B0D2D7\" rows=\"10\" name=\"entry\" cols=\"48\" >{$row['entry']}</textarea> <br> <p align=\"left\"><INPUT type=\"submit\" name=\"edit_misc\" value=\"Save\"></p> <input type=\"hidden\" name=\"id\" value=\"".$_GET['id']."\"> </form> </td> </table> "; } ?> The code in editm.php script is : <?php // [start] Save changes for misc ini_set ('display_errors',1); error_reporting (E_ALL); if (isset ($_POST['edit_misc'])){ if ($dbc = @mysql_connect('localhost','user','p@ss')) { if (!@mysql_select_db ('web_site')) { die('<p> Could not select the database brcause:<b>'. mysql_error() .'</b></p>'); } }else{ die('<p>Could not connect to MYSQL because:<b>' . mysql_error() . '</b></p>'); } $queryb = "UPDATE misc_entries SET title='{$_POST['title']}',entry='{$_POST['entry']}' WHERE id={$_POST['id']}"; if (@mysql_query ($queryb)){ echo "<meta http-equiv='refresh' content='0;URL=edmp.php'>"; }else{ print"<p>Could not add the entry because:<b>" .mysql_error() . "</b>. The query was $query.</p>"; } mysql_close(); } ?> Tha problem is that when i press the save button it doesn't update the db. Also i have to add here that i do the exactly the same thing with another table and there it works fine ... Can you see any mistake here? Thanks... -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Something going wrong with quotes... -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
here is the line : <input style="background:#B0D2D7" type="text" name="title" size="38" value="<a href ="www.google.com">Google</a>"> Only the "<a href =" is in the box -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Ok i have this : <?php if(isset($_GET['action']) && $_GET['action']=="edit"){ $q = mysql_query("SELECT title,entry FROM site_entries WHERE id='".mysql_real_escape_string($_GET['id'])."'"); $row = mysql_fetch_array($q); print " <br> <table align=\"center\"><td> <form method=\"post\" name=\"misc\" action=\"edmp.php\" > <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\" >\$title :</font> <br> <input style=\"background:#B0D2D7\" type=\"text\" name=\"title\" size=\"38\" value=\"{$row['title']}\"> <br><br> <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\">\$text:</font> <br> <textarea style=\"background:#B0D2D7\" rows=\"10\" name=\"entry\" cols=\"48\" ></textarea> <br> <p align=\"center\"><INPUT type=\"submit\" name=\"submit1\" value=\"Submit\"></p> </form> </td> </table> "; } ?> But when it prints the form the Title is out of the text box lol and its near it.. Something is not good in this line.. I change it a little bit but... i didnt found anything.. <input style=\"background:#B0D2D7\" type=\"text\" name=\"title\" size=\"38\" value=\"{$row['title']}\"> -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Hmmm I need your help once again... i add this for the edit link <?php if(isset($_GET['action']) && $_GET['action']=="edit"){ print "<br><table align=\"center\"><td> <form method=\"post\" name=\"misc\" action=\"edmp.php\" > <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\" >\$title :</font> <br> <input style=\"background:#B0D2D7\" type=\"text\" name=\"title\" size=\"38\" value={$row['title']}> <br><br> <font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#FFF380\">\$text:</font> <br> <textarea style=\"background:#B0D2D7\" rows=\"10\" name=\"entry\" cols=\"48\" ></textarea> <br> <p align=\"center\"><INPUT type=\"submit\" name=\"submit1\" value=\"Submit\"></p> </form> </td></table>"; } ?> I want to ask you how in the text and in the textarea i will load the title and the entry text from the database with the specific id number... Any ideas... Thanks... -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Hmmm done i change in my code this : $query = "DELETE FROM site_entries WHERE id={$row['id']} LIMIT 1"; into this : $query = "DELETE FROM site_entries WHERE id={$_GET['id']} LIMIT 1"; haha lol when im posting this reply you had already post yours... -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Hmm see here i add some code for errors and i get this one back: -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Still doesnt work... <table align="center" border="2" bordercolor="green" cellspacing="0"><?php $query = 'SELECT title,id FROM site_entries ORDER BY date_entered DESC'; if ($r = mysql_query($query)){ while ($row = mysql_fetch_array($r)){ print " <tr> <td><font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#8BB381\">{$row['title']}</td> <td><a href=\"{$_SERVER['PHP_SELF']}?action=delete&id={$row['id']}\">Delete();</a></td> <td><a href=\"{$_SERVER['PHP_SELF']}?action=edit&id={$row['id']}\">Edit();</a></td> </tr> "; } }else{ die('<p>Could not retrive the data brcause:<b>' . mysql_error .'</b> The query was $query.</p>'); } if(isset($_GET['action']) && $_GET['action']=="delete"){ $query = "DELETE FROM site_entries WHERE id={$row['id']} LIMIT 1"; $r = mysql_query($query); } mysql_close(); ?></table> -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Hmm some edit... I make a refresh and the error doesn't appeared ... But if i go to delete link it doesn't deletes the register.I m still believing that the error is in the $_GET checking part... -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
Thank you a lot seanlim for your answers... So after 6 tries with $_POST i decide to make it with the last way you say... Here is my code now: <?php $query = 'SELECT title,id FROM site_entries ORDER BY date_entered DESC'; if ($r = mysql_query($query)){ while ($row = mysql_fetch_array($r)){ print " <tr> <td><font face=\"Lucida Console, Courier New, Fixed\" size=2 color=\"#8BB381\">{$row['title']}</td> <td><a href=\"{$_SERVER['PHP_SELF']}?action=delete&id={$row['id']}\">Delete();</a></td> <td><a href=\"{$_SERVER['PHP_SELF']}?action=edit&id={$row['id']}\">Edit();</a></td> </tr> "; } }else{ die('<p>Could not retrive the data brcause:<b>' . mysql_error .'</b> The query was $query.</p>'); } if ($_GET['action'] == "delete"){ $query = "DELETE FROM site_entries WHERE id={$row['id']} LIMIT 1"; $r = mysql_query($query); } mysql_close(); ?> It returns me this error Notice: Undefined index: action in /var/www/login/edmp.php on line 259 and i thing that i have an error in the checking $_GET['action'] part...in the if clause..What do you think ? Also i have another question...Ok.. with delete link its just execute a DELETE query...what happens with the edit ? Maybe this one needs a POST method i think..cuz it needs a form with the new title and text ...Thats my opinion..Except if we can make it to redirects you to a new edit page... Thanks for all!! I really mean it.. You help me to learn lot of things . -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
First i want to test it with post method.. Anyway.. i change as you say the php script to another file . delete.php and there i add print_r($_POST); line... I get this: Array ( [23] => Delete(); ) It takes the id=23 as we can see...and the button's value = Delete(); How i can make it work with DELETE query ? I ll try it later with $_GET but im curious now on how it works with POST. Here is the code once again with some changes: delete.php <?php //[start] of DeleteOrEdit section ini_set('display_errors',1); error_reporting(E_ALL); if ($dbc = @mysql_connect('localhost','we','p@ss')) { if (!@mysql_select_db ('web_site')) { die('<p> Could not select the database brcause:<b>'. mysql_error() .'</b></p>'); } }else{ die('<p>Could not connect to MYSQL because:<b>' . mysql_error() . '</b></p>'); } //Deleting a register if (isset($_POST['submit'])){ $query = "DELETE FROM site_entries WHERE id={$row['id']} LIMIT 1"; $r = mysql_query($query); } print_r($_POST); mysql_close(); ?> edmp.php <form method="post" action="delete.php"> <table align="center" border="2" bordercolor="green" cellspacing="0"> <tr> <td><font color="#F87217">Title:</td> <td><font color="#F87217">Delete();</font></td> <td><font color="#F87217">Edit();</font></td> </tr> <?php $query = 'SELECT title,id FROM site_entries ORDER BY date_entered DESC'; if ($r = mysql_query($query)){ while ($row = mysql_fetch_array($r)){ print " <tr> <td><font color=\"#8BB381\">{$row['title']}</td> <td><input type=\"submit\" name=\"{$row['id']}\" value=\"Delete();\"></td> <td><input type=\"submit\" name=\"{$row['id']}\" value=\"Edit();\"></td> </tr> "; } }else{ die('<p>Could not retrive the data brcause:<b>' . mysql_error .'</b> The query was $query.</p>'); } mysql_close(); ?> </table> </form> -
[SOLVED] Help With editting and deleting form
netpumber replied to netpumber's topic in PHP Coding Help
hmm...Seanlim... i do what you said an here is the new code: <form method="post" action="edmp.php"> <table align="center" border="2" bordercolor="green" cellspacing="0"> <tr> <td><font color="#F87217">Title:</td> <td><font color="#F87217">Delete();</font></td> <td><font color="#F87217">Edit();</font></td> </tr> <?php $query = 'SELECT title,id FROM site_entries ORDER BY date_entered DESC'; if ($r = mysql_query($query)){ while ($row = mysql_fetch_array($r)){ print " <tr> <td><font color=\"#8BB381\">{$row['title']}</td> <td><input type=\"submit\" name=\"{$row['id']}\" value=\"Delete();\"></td> <td><input type=\"submit\" name=\"{$row['id']}\" value=\"Edit();\"></td> </tr> "; } }else{ die('<p>Could not retrive the data brcause:<b>' . mysql_error .'</b> The query was $query.</p>'); } ?> </table> </form> <?php //Deleting a register if (isset($_POST['submit'])){ $query = "DELETE FROM site_entries WHERE id={$row['id']} LIMIT 1"; $r = mysql_query($query); } mysql_close(); ?> the prob is that when i press the delete button nothing happens... Maybe something is going wrong with the {$row['id']} but i dont know...What you say? -
Hallo !! So look at this image : http://img194.imageshack.us/img194/8272/snapshot5f.png This table prints the titles of entries from a table in a database.. The code that i use for this table is this : <!--Table For Deleting and Updating --> <br> <br> <p align="center"><font color="#1569C7">DeleteOrEdit(</font><font color="red">Security Projects & Thoughts Section</font><font color="#1569C7">);</font></p> <table align="center" border="2" bordercolor="green" cellspacing="0"> <!--First row with title delete and edit--> <tr> <td><font color="#F87217">Title:</td> <td><font color="#F87217">Delete();</font></td> <td><font color="#F87217">Edit();</font></td> </tr> <?php $query = 'SELECT title FROM site_entries ORDER BY date_entered DESC'; if ($r = mysql_query($query)){ while ($row = mysql_fetch_array($r)){ print "<tr> <td><font color=\"#8BB381\">{$row['title']}</td> <td><form method=\"post\" name=\"sub_del\"><input type=\"submit\" value=\"Delete();\"></form></td> <td><form method=\"post\" name=\"sub_edt\"><input type=\"submit\" value=\"Edit();\"></form></td> </tr> "; } }else{ die('<p>Could not retrive the data brcause:<b>' . mysql_error .'</b> The query was $query.</p>'); } mysql_close(); ?> </table> Its simple...till here... Now i stack on how to make the script that will delete the registers of the database...I can think something with id column but i can't make it true...:s I want you to help me giving me ideas on how to make this or any other idea on how to create an delete/edit page...If you think that i start it with a wrong way please tell me The table name is site_entries and its columns are id , title , entry , date_entered Thanks in advance..!!
-
Hallo!! I want to ask you something about redirection . I have a site eg. http://pop.homeserver.net and i have install the ssl protocol and make it work with apache. Now i want to make apache when someone visit http://pop.homeserver.net then automatically redirect him in https://pop.homeserver.net . Is there any way to make it ?
-
[SOLVED] header() function help in login.php
netpumber replied to netpumber's topic in PHP Coding Help
Oh YEAH thanks A LOT cags... I add a session_start(); in admin.php and worked .. Thanks a lot all of you guyz!! This board roolez!! Keep up the good work... PROBLEM SOLVED!! -
[SOLVED] header() function help in login.php
netpumber replied to netpumber's topic in PHP Coding Help
Hmmm i see something curious... If i type the correct password the error under the echo $query; is : and if i type a wrong password the error become : What you say ..? -
[SOLVED] header() function help in login.php
netpumber replied to netpumber's topic in PHP Coding Help
lol ..no .. The error : Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/login/login.php:23) in /var/www/login/login.php on line 27 Warning: Cannot modify header information - headers already sent by (output started at /var/www/login/login.php:23) in /var/www/login/login.php on line 31 occurs because i have type in the code echo $query; to see if the query do the right things... -
[SOLVED] header() function help in login.php
netpumber replied to netpumber's topic in PHP Coding Help
Ok i ll try to saw you how is my db.. Name: web_site Here are tow screenshots: http://img34.imageshack.us/img34/3070/snapshot1f.png and http://img41.imageshack.us/img41/9457/snapshot2j.png And here is the query echoing... http://img21.imageshack.us/img21/1003/snapshot3h.png Are all good in my opinion..:s -
[SOLVED] header() function help in login.php
netpumber replied to netpumber's topic in PHP Coding Help
nothing eh...? 4 days now im trying to find what is not working good...It crazy... Anyway... you suggest me any other way to create my login page? -
[SOLVED] header() function help in login.php
netpumber replied to netpumber's topic in PHP Coding Help
Oh ok... doesn't matter... I remove them but nothing... OMG I just want a simple login page!!!! what the hell!!!