Jump to content

Blog - Add New Entry


alexcrosson

Recommended Posts

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:
[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>[/code]

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:
[quote]This seems to work.
Add Entry
Title:
Content:[/quote]

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.
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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:
[code]
<?php
if(isset($_POST['submit'])){
echo "This seems to work"
}
?>
[/code]
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.
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.