Using dyanmaic URLs and need some help with a form
- 74123
- Graduate


- Joined: Jul 06, 2005
- Posts: 190
- Status: Offline
PHP Code: [ Select ]
<?php
include("config/config.php");
if($submit)
{
$title = $_POST['title'];
$name = $_POST['name'];
$content = $_POST['content'];
$result = mysql_query("UPDATE news SET title='$title', name='$name', content='$content' WHERE id='$id' ",$connect);
echo "<b><strong>Thank you! News UPDATED Successfully!</strong>";
// echo "<meta http-equiv=Refresh content=2;url=../index.php target='_self'>";
}
elseif($id)
{
$result = mysql_query("SELECT * FROM news WHERE id='$id' ",$connect);
while($row = mysql_fetch_assoc($result))
{
$title = $row["title"];
$name = $row["name"];
$content = $row["content"];
?>
<form action="<? echo $PHP_SELF ?>" method="post" name="form">
<p>
<p>Name :<br />
<input name="name" size="40" maxlength="20" value="<? echo $name; ?>">
<br />
Headline:<br />
<input name="title" size="40" maxlength="255" value="<? echo $title; ?>">
<br />
<br />
<input onClick="document.form.news.value+=''" type="button" value="Bold">
<input onClick="document.form.news.value+=''" type="button" value="Italic">
<input onClick="document.form.news.value+=''" type="button" value="Underlined">
<input onClick="document.form.news.value+='[img src=http://]'" type="button" value="Image">
<input onClick="document.form.news.value+='[url=http://]Link[/url]'" type="button" value="URL">
<br>
<span class="style4"><em>Example: <br>
</em>[img src=http://<span class="style1">www.url.com/image.jpg</span>]<br>
[url=http://<span class="style1">www.url.com</span>]<span class="style1">URL Title</span>[/url] <br />
</span><br />
<a href="javascript:;" onClick="document.form.news.value+=':@'"><img src="images/smilies/angry.gif" alt=":@" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':D'"><img src="images/smilies/biggrin.gif" alt=":D" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':S'"><img src="images/smilies/confused.gif" alt=":S" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+='B)'"><img src="images/smilies/cool.gif" alt="B)" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':)'"><img src="images/smilies/happy.gif" alt=":)" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':|'"><img src="images/smilies/mellow.gif" alt=":|" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':('"><img src="images/smilies/sad.gif" alt=":(" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':P'"><img src="images/smilies/tongue.gif" alt=":P" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=';)'"><img src="images/smilies/wink.gif" alt=";)" height="15" width="15" /></a><br />
<br />
<textarea name="content" rows="15" cols="75"><? echo $content; ?></textarea>
<br />
<br />
<input name="submit" type="submit" value="submit" />
</form>
<?
}
?>
- <?php
- include("config/config.php");
- if($submit)
- {
- $title = $_POST['title'];
- $name = $_POST['name'];
- $content = $_POST['content'];
- $result = mysql_query("UPDATE news SET title='$title', name='$name', content='$content' WHERE id='$id' ",$connect);
- echo "<b><strong>Thank you! News UPDATED Successfully!</strong>";
- // echo "<meta http-equiv=Refresh content=2;url=../index.php target='_self'>";
- }
- elseif($id)
- {
- $result = mysql_query("SELECT * FROM news WHERE id='$id' ",$connect);
- while($row = mysql_fetch_assoc($result))
- {
- $title = $row["title"];
- $name = $row["name"];
- $content = $row["content"];
- ?>
- <form action="<? echo $PHP_SELF ?>" method="post" name="form">
- <p>
- <p>Name :<br />
- <input name="name" size="40" maxlength="20" value="<? echo $name; ?>">
- <br />
- Headline:<br />
- <input name="title" size="40" maxlength="255" value="<? echo $title; ?>">
- <br />
- <br />
- <input onClick="document.form.news.value+=''" type="button" value="Bold">
- <input onClick="document.form.news.value+=''" type="button" value="Italic">
- <input onClick="document.form.news.value+=''" type="button" value="Underlined">
- <input onClick="document.form.news.value+='[img src=http://]'" type="button" value="Image">
- <input onClick="document.form.news.value+='[url=http://]Link[/url]'" type="button" value="URL">
- <br>
- <span class="style4"><em>Example: <br>
- </em>[img src=http://<span class="style1">www.url.com/image.jpg</span>]<br>
- [url=http://<span class="style1">www.url.com</span>]<span class="style1">URL Title</span>[/url] <br />
- </span><br />
- <a href="javascript:;" onClick="document.form.news.value+=':@'"><img src="images/smilies/angry.gif" alt=":@" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':D'"><img src="images/smilies/biggrin.gif" alt=":D" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':S'"><img src="images/smilies/confused.gif" alt=":S" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+='B)'"><img src="images/smilies/cool.gif" alt="B)" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':)'"><img src="images/smilies/happy.gif" alt=":)" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':|'"><img src="images/smilies/mellow.gif" alt=":|" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':('"><img src="images/smilies/sad.gif" alt=":(" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':P'"><img src="images/smilies/tongue.gif" alt=":P" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=';)'"><img src="images/smilies/wink.gif" alt=";)" height="15" width="15" /></a><br />
- <br />
- <textarea name="content" rows="15" cols="75"><? echo $content; ?></textarea>
- <br />
- <br />
- <input name="submit" type="submit" value="submit" />
- </form>
- <?
- }
- ?>
I get this error:
Code: [ Select ]
Parse error: parse error, unexpected $ in /var/www/verysecretsite.com/public_html/verysecretsite_final/includes/admin/panels/news/edit.php on line 68
Any help would be great.
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
October 7th, 2005, 7:39 pm
- ATNO/TW
- Super Moderator


- Joined: May 28, 2003
- Posts: 23407
- Loc: Woodbridge VA
- Status: Offline
PHP Code: [ Select ]
<form action="<? echo $PHP_SELF ?>" method="post" name="form">
Where is $PHP_SELF defined in your code? That would be my first question.
I'm also assuming line 68 is the end line of your code which typically occurs if there is a parse error such as this:
Quote:
Parse error: parse error, unexpected $ in
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
- 74123
- Graduate


- Joined: Jul 06, 2005
- Posts: 190
- Status: Offline
from what I undersyand, $PHP_SELF just tells it to submit the page to itself, it doesnt need to be defined.
I dont know whats wrong there, I ended up just rewriting the whole thing and its working. as far as i can tell there is nothing different (of any significance) in the new one.
I dont know whats wrong there, I ended up just rewriting the whole thing and its working. as far as i can tell there is nothing different (of any significance) in the new one.
- ATNO/TW
- Super Moderator


- Joined: May 28, 2003
- Posts: 23407
- Loc: Woodbridge VA
- Status: Offline
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
- 74123
- Graduate


- Joined: Jul 06, 2005
- Posts: 190
- Status: Offline
Im having a problem with submitting a form to itself so it will upload to a db. I tried the page by itself without using includes and it works. I have tried:
as my forma action. Yes, I am telling it to post.
When I have the page by itself it works just fine, but if im trying to include it in index.php it doesnt work, once you hit submit, it just shows you the index page.
Page Code:
Code: [ Select ]
http://www.somewebsite.com/somewebsite_final/includes/admin/panels/news/add.php
Code: [ Select ]
index.php?content=admin§ion=panel&edit=news&action=add
Code: [ Select ]
<?php echo $_SERVER['PHP_SELF'];?>
as my forma action. Yes, I am telling it to post.
When I have the page by itself it works just fine, but if im trying to include it in index.php it doesnt work, once you hit submit, it just shows you the index page.
Page Code:
Code: [ Select ]
<?php
//beginning of Add news
include("../../../../config/config.php");
if($submit)
{
$title = $_POST['title'];
$name = $_POST['name'];
$content = $_POST['content'];
if(!$content){
echo "Error: News is a required field. Please fill it.";
exit();
}
$result = mysql_query("INSERT INTO news (title, name, dtime, content)
VALUES ('$title','$name',NOW(),'$content')",$connect);
echo "<b><strong>Thank you! News added Successfully!</strong>";
// echo "<meta http-equiv=Refresh content=2;url=view.php target='_self'>";
}
else
{
?>
<form method="post" action="http://www.somewebsite.com/somewebsite_final/includes/admin/panels/news/add.php">
Name: <br>
<input name="name" size="40" maxlength="20">
<br>
Title:<br>
<input name="title" size="40" maxlength="255">
<br>
News: <br>
<input onClick="document.form.news.value+='[b][/b]'" type="button" value="Bold">
<input onClick="document.form.news.value+='[i][/i]'" type="button" value="Italic">
<input onClick="document.form.news.value+='[u][/u]'" type="button" value="Underlined">
<input onClick="document.form.news.value+='[img src=http://]'" type="button" value="Image">
<input onClick="document.form.news.value+='[url=http://]Link[/url]'" type="button" value="URL">
<br />
<a href="javascript:;" onClick="document.form.news.value+=':@'"><img src="images/smilies/angry.gif" alt=":@" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':D'"><img src="images/smilies/biggrin.gif" alt=":D" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':S'"><img src="images/smilies/confused.gif" alt=":S" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+='B)'"><img src="images/smilies/cool.gif" alt="B)" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':)'"><img src="images/smilies/happy.gif" alt=":)" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':|'"><img src="images/smilies/mellow.gif" alt=":|" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':('"><img src="images/smilies/sad.gif" alt=":(" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':P'"><img src="images/smilies/tongue.gif" alt=":P" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=';)'"><img src="images/smilies/wink.gif" alt=";)" height="15" width="15" /></a><br />
<textarea name="content" rows="15" cols="75"></textarea>
<br>
<input type="submit" name="submit" value="Add News">
</form>
<?
}
//End of Add news
?>
//beginning of Add news
include("../../../../config/config.php");
if($submit)
{
$title = $_POST['title'];
$name = $_POST['name'];
$content = $_POST['content'];
if(!$content){
echo "Error: News is a required field. Please fill it.";
exit();
}
$result = mysql_query("INSERT INTO news (title, name, dtime, content)
VALUES ('$title','$name',NOW(),'$content')",$connect);
echo "<b><strong>Thank you! News added Successfully!</strong>";
// echo "<meta http-equiv=Refresh content=2;url=view.php target='_self'>";
}
else
{
?>
<form method="post" action="http://www.somewebsite.com/somewebsite_final/includes/admin/panels/news/add.php">
Name: <br>
<input name="name" size="40" maxlength="20">
<br>
Title:<br>
<input name="title" size="40" maxlength="255">
<br>
News: <br>
<input onClick="document.form.news.value+='[b][/b]'" type="button" value="Bold">
<input onClick="document.form.news.value+='[i][/i]'" type="button" value="Italic">
<input onClick="document.form.news.value+='[u][/u]'" type="button" value="Underlined">
<input onClick="document.form.news.value+='[img src=http://]'" type="button" value="Image">
<input onClick="document.form.news.value+='[url=http://]Link[/url]'" type="button" value="URL">
<br />
<a href="javascript:;" onClick="document.form.news.value+=':@'"><img src="images/smilies/angry.gif" alt=":@" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':D'"><img src="images/smilies/biggrin.gif" alt=":D" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':S'"><img src="images/smilies/confused.gif" alt=":S" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+='B)'"><img src="images/smilies/cool.gif" alt="B)" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':)'"><img src="images/smilies/happy.gif" alt=":)" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':|'"><img src="images/smilies/mellow.gif" alt=":|" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':('"><img src="images/smilies/sad.gif" alt=":(" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=':P'"><img src="images/smilies/tongue.gif" alt=":P" height="15" width="15" /></a>
<a href="javascript:;" onClick="document.form.news.value+=';)'"><img src="images/smilies/wink.gif" alt=";)" height="15" width="15" /></a><br />
<textarea name="content" rows="15" cols="75"></textarea>
<br>
<input type="submit" name="submit" value="Add News">
</form>
<?
}
//End of Add news
?>
- <?php
- //beginning of Add news
- include("../../../../config/config.php");
- if($submit)
- {
- $title = $_POST['title'];
- $name = $_POST['name'];
- $content = $_POST['content'];
- if(!$content){
- echo "Error: News is a required field. Please fill it.";
- exit();
- }
- $result = mysql_query("INSERT INTO news (title, name, dtime, content)
- VALUES ('$title','$name',NOW(),'$content')",$connect);
- echo "<b><strong>Thank you! News added Successfully!</strong>";
- // echo "<meta http-equiv=Refresh content=2;url=view.php target='_self'>";
- }
- else
- {
- ?>
- <form method="post" action="http://www.somewebsite.com/somewebsite_final/includes/admin/panels/news/add.php">
- Name: <br>
- <input name="name" size="40" maxlength="20">
- <br>
- Title:<br>
- <input name="title" size="40" maxlength="255">
- <br>
- News: <br>
- <input onClick="document.form.news.value+='[b][/b]'" type="button" value="Bold">
- <input onClick="document.form.news.value+='[i][/i]'" type="button" value="Italic">
- <input onClick="document.form.news.value+='[u][/u]'" type="button" value="Underlined">
- <input onClick="document.form.news.value+='[img src=http://]'" type="button" value="Image">
- <input onClick="document.form.news.value+='[url=http://]Link[/url]'" type="button" value="URL">
- <br />
- <a href="javascript:;" onClick="document.form.news.value+=':@'"><img src="images/smilies/angry.gif" alt=":@" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':D'"><img src="images/smilies/biggrin.gif" alt=":D" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':S'"><img src="images/smilies/confused.gif" alt=":S" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+='B)'"><img src="images/smilies/cool.gif" alt="B)" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':)'"><img src="images/smilies/happy.gif" alt=":)" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':|'"><img src="images/smilies/mellow.gif" alt=":|" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':('"><img src="images/smilies/sad.gif" alt=":(" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=':P'"><img src="images/smilies/tongue.gif" alt=":P" height="15" width="15" /></a>
- <a href="javascript:;" onClick="document.form.news.value+=';)'"><img src="images/smilies/wink.gif" alt=";)" height="15" width="15" /></a><br />
- <textarea name="content" rows="15" cols="75"></textarea>
- <br>
- <input type="submit" name="submit" value="Add News">
- </form>
- <?
- }
- //End of Add news
- ?>
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13458
- Loc: Florida
- Status: Offline
- 74123
- Graduate


- Joined: Jul 06, 2005
- Posts: 190
- Status: Offline
1) <input type="submit" name="submit" value="Add News">
2) No, it shows the news (as defaults). It doesnt display "Thank you! News added Successfully!" Like it should.
Index.php is:
Of course it also has the gfx and html.
2) No, it shows the news (as defaults). It doesnt display "Thank you! News added Successfully!" Like it should.
Index.php is:
Code: [ Select ]
<?
switch($content) {
case "index":
include ("includes/news/index.php");
break;
case "admin":
include ("includes/admin/index.php");
break;
case "hand_of_choice":
include ("includes/hand_of_choice/index.php");
break;
case "handhistory":
include ("includes/handhistory/index.php");
break;
case "way_to_vegas":
include ("includes/way_to_vegas/index.php");
break;
case "*plum*":
include ("includes/*plum*/index.php");
break;
case "forum":
include ("includes/forum/index.php");
break;
case "donations":
include ("includes/donations/index.php");
break;
case "contact":
include ("includes/contact/index.php");
break;
case "challenge":
include ("includes/challenge/index.php");
break;
case "join":
include ("includes/join/index.php");
break;
case "showhand":
include ("includes/showhand/index.php");
break;
default:
include ("includes/news/index.php");
break;
}
?>
switch($content) {
case "index":
include ("includes/news/index.php");
break;
case "admin":
include ("includes/admin/index.php");
break;
case "hand_of_choice":
include ("includes/hand_of_choice/index.php");
break;
case "handhistory":
include ("includes/handhistory/index.php");
break;
case "way_to_vegas":
include ("includes/way_to_vegas/index.php");
break;
case "*plum*":
include ("includes/*plum*/index.php");
break;
case "forum":
include ("includes/forum/index.php");
break;
case "donations":
include ("includes/donations/index.php");
break;
case "contact":
include ("includes/contact/index.php");
break;
case "challenge":
include ("includes/challenge/index.php");
break;
case "join":
include ("includes/join/index.php");
break;
case "showhand":
include ("includes/showhand/index.php");
break;
default:
include ("includes/news/index.php");
break;
}
?>
- <?
- switch($content) {
- case "index":
- include ("includes/news/index.php");
- break;
- case "admin":
- include ("includes/admin/index.php");
- break;
- case "hand_of_choice":
- include ("includes/hand_of_choice/index.php");
- break;
- case "handhistory":
- include ("includes/handhistory/index.php");
- break;
- case "way_to_vegas":
- include ("includes/way_to_vegas/index.php");
- break;
- case "*plum*":
- include ("includes/*plum*/index.php");
- break;
- case "forum":
- include ("includes/forum/index.php");
- break;
- case "donations":
- include ("includes/donations/index.php");
- break;
- case "contact":
- include ("includes/contact/index.php");
- break;
- case "challenge":
- include ("includes/challenge/index.php");
- break;
- case "join":
- include ("includes/join/index.php");
- break;
- case "showhand":
- include ("includes/showhand/index.php");
- break;
- default:
- include ("includes/news/index.php");
- break;
- }
- ?>
Of course it also has the gfx and html.
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13458
- Loc: Florida
- Status: Offline
In the form,
The first one you posted
Use this action.
In "index.php"
Before the switch
Add this,
That should at least get you into includes/admin/index.php if not through the entire script.
The first one you posted
Use this action.
Code: [ Select ]
action="<?php echo $_SERVER['PHP_SELF'] . '?content=admin§ion=panel&edit=news&action=add'; ?>"
In "index.php"
Before the switch
Add this,
Code: [ Select ]
$submit = false;
$content = false;
$section = false;
$edit = false;
$action = false;
if(!empty($_POST['submit']))
{
$submit = $_POST['submit'];
}
if(!empty($_GET['content']))
{
$content = $_GET['content'];
}
if(!empty($_GET['section']))
{
$section = $_GET['section'];
}
if(!empty($_GET['edit']))
{
$edit = $_GET['edit'];
}
if(!empty($_GET['action']))
{
$action = $_GET['action'];
}
$content = false;
$section = false;
$edit = false;
$action = false;
if(!empty($_POST['submit']))
{
$submit = $_POST['submit'];
}
if(!empty($_GET['content']))
{
$content = $_GET['content'];
}
if(!empty($_GET['section']))
{
$section = $_GET['section'];
}
if(!empty($_GET['edit']))
{
$edit = $_GET['edit'];
}
if(!empty($_GET['action']))
{
$action = $_GET['action'];
}
- $submit = false;
- $content = false;
- $section = false;
- $edit = false;
- $action = false;
- if(!empty($_POST['submit']))
- {
- $submit = $_POST['submit'];
- }
- if(!empty($_GET['content']))
- {
- $content = $_GET['content'];
- }
- if(!empty($_GET['section']))
- {
- $section = $_GET['section'];
- }
- if(!empty($_GET['edit']))
- {
- $edit = $_GET['edit'];
- }
- if(!empty($_GET['action']))
- {
- $action = $_GET['action'];
- }
That should at least get you into includes/admin/index.php if not through the entire script.
Strong with this one, the sudo is.
- 74123
- Graduate


- Joined: Jul 06, 2005
- Posts: 190
- Status: Offline
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13458
- Loc: Florida
- Status: Offline
Glad it works, just make sure your variables are going through security checks later on (if not in that addition) and do me a favor, don't start new topics on the same issue like this anymore, it gets confusing. Posting to the original thread with tales of your progress makes things much easier.
Strong with this one, the sudo is.
- 74123
- Graduate


- Joined: Jul 06, 2005
- Posts: 190
- Status: Offline
I googled security checks and the results I recieved were a bit confusing. What do you mean exactly?
I have moved the website to a different server and now when I click on the link to edit the contents, it doesnt work. It just reloads and shows the list of things that I can edit. Does the server need to have something enabled for it to work?
I have moved the website to a different server and now when I click on the link to edit the contents, it doesnt work. It just reloads and shows the list of things that I can edit. Does the server need to have something enabled for it to work?
- Funny_Fuzz
- Mastermind


- Joined: Jan 18, 2005
- Posts: 1517
- Status: Offline
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 12 posts
- Users browsing this forum: No registered users and 87 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
