PHP/MySQL Forms and Output

I’m writing a small daily devotional form for my church’s website and its works fine for the most part but there are 2 smaller issues I am having and would love some advice.

  1. The the bottom table 'Devotional", i need to be a text area, but I cannot seem to make that work right. If I make it a text area it will not update it in the database when I select Edit.

  2. The 2 buttons at the bottom only work separately if they are in separate forms, I am trying to place them in the same form and side by side.

here is the code:

[php]<?php
include ‘core/init.php’;
protect_page();
include ‘includes/overall/overallheader.php’;
?>

<?php include 'includes/admin_menu.php'; ?> <?php include('connection.php'); $query="SELECT * FROM `devotional`"; $resource=mysql_query($query); ?>

Daily Devotional

<?php $_id = (int)($_GET['id']); $_sql ="SELECT * FROM `devotional`"; $_rs = mysql_query($_sql); while($_rw = mysql_fetch_assoc($_rs)) { $_id = $_rw['id']; $_date = $_rw['date']; $_title = $_rw['title']; $_author = $_rw['author']; $_verse = $_rw['verse']; $_devotional = $_rw['devotional']; } ?> <?PHP if(isset($_POST['edit'])) { $_date = mysql_real_escape_string($_POST['_date']); $_title = mysql_real_escape_string($_POST['_title']); $_author = mysql_real_escape_string($_POST['_author']); $_verse = mysql_real_escape_string($_POST['_verse']); $_devotional = mysql_real_escape_string($_POST['_devotional']); $_id = (int)$_POST['id']; $_SQL = "UPDATE `devotional` SET `date`='$_date', `title`='$_title', `author`='$_author', `verse`='$_verse', `devotional`='$_devotional' WHERE `id`='$_id'"; mysql_query($_SQL) or die(mysql_error()); //header("Location : index.php?id=$_id"); $_html =" RECORD HAS BEEN UPDATED CLICK HERE "; } elseif(isset($_POST['delete'])) { $id = (int)$_POST['id']; mysql_query("DELETE FROM `devotional` WHERE `id`='$id' LIMIT 1"); $_html = 'Record deleted successfully!
CLICKHERE.'; if ("default" != GetFileName($_POST['_front'])){ unlink($_POST['_front']); } if ("default" != GetFileName($_POST['_rear'])){ unlink($_POST['_rear']); } if ("default" != GetFileName($_POST['_right'])){ unlink($_POST['_right']); } if ("default" != GetFileName($_POST['_left'])){ unlink($_POST['_left']); } if ("default" != GetFileName($_POST['_intfront'])){ unlink($_POST['_intfront']); } if ("default" != GetFileName($_POST['_intrear'])){ unlink($_POST['_intrear']); } } else { $_html="
Date:

Title:

Author:

verse:


Devotional:



"; } ?> <?php echo $_html; ?> <?php include 'includes/overall/overallfooter.php'; ?> [/php]

I fixed the second issue, it was the hidden inputs that were causing the issue. Still cant figure out why I cant get a simple textarea to work.

You need a not a field look at this page for text area information http://www.echoecho.com/htmlforms08.htm

also make sure your database field is large enough for the text being entered.

Thank you for the replay. I followed what the tutorial said, however, it did not work right.

This does create the text area, but it does not populate the text area with what is in the database like it does when I use an tag.

[php]

Devotional:


[/php]

this is used for inputs not text areas
[php]value="$_devotional"[/php]

try this

[php]
<textarea cols=“40” rows=“5” name="_devotional">$_devotional [/php]

You guys are awesome, thank you guys very much. It works like a charm now :slight_smile:

<----------he likes karma :smiley:
No problem glad to help :smiley:

solved

Sponsor our Newsletter | Privacy Policy | Terms of Service