Jump to content


Photo

Blog - Add New Entry


  • Please log in to reply
4 replies to this topic

#1 alexcrosson

alexcrosson
  • Members
  • PipPip
  • Member
  • 21 posts

Posted 02 October 2006 - 12:02 AM

Okay i'll try to explain this as best as possible. There is the main.php page. and when you click a link name Add Entry, it includes add_entry.php

Here is the add_entry.php code:
<?php
if(isset($_POST['submit'])); {
	echo "This seems to work"
}
?>
<h2>Add Entry</h2>
<form name="Add Entry" action="<?php echo $_POST['a']=add_entry; $_SERVER['PHP_SELF'];?>" method="POST">
<label for="title">Title:</label>
<input name="blgtitle" id="blgtitle" type="text" />
<label for="content">Content:</label>
<textarea name="blgcontent" cols="35" rows="4" id="blgcontent"></textarea>
<p>
<input type="submit" name="submit" value="Submit" />
</p>
</form>

Its pretty basic. This is wear I will be able to add blog entries but i have some problems. When my site includes this page it gives me the following output:

This seems to work.
Add Entry
Title:
Content:


The "This seems to work" part should only display when the form has been submited right? And the <? $_SERVER['PHP_SELF'];?> won't work because it reloads the main.php page, not the add_entry.php

This may seem really complicated but maybe you can help.

#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 02 October 2006 - 08:21 AM

I might be having a slow day but don't understand why you are going about this the way you are. Why not just put the location that you want the form to post to in the location box. If you want the form to submit to itself you need the $_SERVER['REQUEST_URI'] echoed in the action location on the form header. (this will not work on a windows server)

#3 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 02 October 2006 - 08:24 AM

i am not sure if this will work. but i have never had anything like this. you have a ; after the if statement. try taking that away. so it would be this:
<?php
if(isset($_POST['submit'])){
	echo "This seems to work"
}
?>
now the $_SERVER['PHP_SELF'] bit. Are you supposed to echo that bit and not the $_POST['a']=add_entry. Because your closing the line with the ; so maybe try echoing the $_SERVER['PHP_SELF'];

Hope i helped.
Good luck with your coding.
Jason / ProjectFear / Jaysonic

#4 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 02 October 2006 - 09:35 AM

yes i have just noticed as well you have no ; after your echo statement. Unless this is just a typo here

#5 JasonLewis

JasonLewis
  • Members
  • PipPipPip
  • Advanced Member
  • 3,351 posts
  • LocationVictoria, Australia

Posted 02 October 2006 - 09:41 AM

oh yeh. that too. add a ; after the echo. lol. thanks steveclondon. i did notice that. i think -_-" :D
Good luck with your coding.
Jason / ProjectFear / Jaysonic




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users