Jump to content

Recommended Posts

I have a form, all the variables that are pulled into the form are showing up fine.

But when you hit "submit, the next page shows nothing. If I try to echo $id or $adress etc... I get nothing.

Any help is appreciated.

Form code:

<form action="submiteventform.php" method="POST">
<input type="hidden" name="eventid" id="eventid" value="<? echo $eventid; ?>">
Date Of Event: <? echo $friendly_date; ?><br />

Place: <? echo $venueinfo['venue']; ?><br />

Author: <? echo $authorname; ?> <br />
Location: <input type="text" name="address" id="address" value="<? echo $venueinfo['address']; ?>"> <br />
<? echo $venueinfo['city']; ?>, 
<? echo $venueinfo['state']; ?> 
<? echo $venueinfo['zip']; ?><br />
Directions: <textarea type="text" rows="8" cols="20" name="directions" id="directions" value="<? echo $venueinfo['directions']; ?>"></textarea><br />
Schedule:<br />
Please schedule no more than three assemblies of 45 minutes each, leaving 5-10 minutes in between.<br />
<?
$schedulequery = ("SELECT * FROM `schedules` WHERE eventid = '$eventid'");
$scheduleresult=mysql_query($schedulequery);
for ($loop=1;$loop<=3;$loop++) {
        if ($scheduleinfo=mysql_fetch_array($scheduleresult)) {
            $time=$scheduleinfo[3];
        } else {
            $time="";
        }

?>
Time:<input type="text" size="8" name="time-<? echo $loop; ?>" id="time" value="<? echo $scheduleinfo['time']; ?>">
Grades:<input type="text" size="8" name="grades-<? echo $loop; ?>" id="grades" value="<? echo $scheduleinfo['grades']; ?>">
Room:<input type="text" size="8" name="room-<? echo $loop; ?>" id="room" value="<? echo $scheduleinfo['room']; ?>">
Notes:<input type="text" name="notes" id="notes-<? echo $loop; ?>" value="<? echo $scheduleinfo['notes']; ?>"><br />
<?
        }
?>
Contact: <? echo $venueinfo['$name']; ?><br />
Phone:<input type="text" size="15" name="phone" id="phone" value="<? echo $venueinfo['phone']; ?>"><br />
Email:<input type="text" size="25" name="email" id="email" value="<? echo $venueinfo['email']; ?>">
Event Notes: <input type="text" size="200" name="eventnotes" id="eventnotes">
<input type="submit" value="Submit">
</form>

submit code:

<?php
include_once("connect.php");

$eventid = $_POST['eventid'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$directions = $_POST['directions'];
$eventnotes = $_POST['eventnotes'];


$query = "UPDATE events SET address='$address', city='$city', state='$state', zip='$zip', directions='$directions', other='$eventnotes' WHERE eventid = '$eventid'";
$result = mysql_query($query);
?>

Link to comment
https://forums.phpfreaks.com/topic/84809-solved-form-variables-not-working/
Share on other sites

<?php
include_once("connect.php");

$eventid = mysql_real_escape_string($_POST['eventid']);
$address = mysql_real_escape_string($_POST['address']);
$city = mysql_real_escape_string($_POST['city']);
$state = mysql_real_escape_string($_POST['state']);
$zip = mysql_real_escape_string($_POST['zip']);
$directions = mysql_real_escape_string($_POST['directions']);
$eventnotes = mysql_real_escape_string($_POST['eventnotes']);

if($_POST['submit']){

$query = "UPDATE events SET address='$address', city='$city', state='$state', zip='$zip', directions='$directions', other='$eventnotes' WHERE eventid = '$eventid'";
$result = mysql_query($query)or die(mysql_error());
}
?>

try both here and below together m8.........

 

<form action="submiteventform.php" method="POST">
<input type="hidden" name="eventid" id="eventid" value="<? echo $eventid; ?>">
Date Of Event: <? echo $friendly_date; ?><br />

Place: <? echo $venueinfo['venue']; ?><br />

Author: <? echo $authorname; ?> <br />
Location: <input type="text" name="address" id="address" value="<? echo $venueinfo['address']; ?>"> <br />
<? echo $venueinfo['city']; ?>, 
<? echo $venueinfo['state']; ?> 
<? echo $venueinfo['zip']; ?><br />
Directions: <textarea type="text" rows="8" cols="20" name="directions" id="directions" value="<? echo $venueinfo['directions']; ?>"></textarea><br />
Schedule:<br />
Please schedule no more than three assemblies of 45 minutes each, leaving 5-10 minutes in between.<br />
<?
$schedulequery = ("SELECT * FROM `schedules` WHERE eventid = '$eventid'");
$scheduleresult=mysql_query($schedulequery);
for ($loop=1;$loop<=3;$loop++) {
        if ($scheduleinfo=mysql_fetch_array($scheduleresult)) {
            $time=$scheduleinfo[3];
        } else {
            $time="";
        }

?>
Time:<input type="text" size="8" name="time-<? echo $loop; ?>" id="time" value="<? echo $scheduleinfo['time']; ?>">
Grades:<input type="text" size="8" name="grades-<? echo $loop; ?>" id="grades" value="<? echo $scheduleinfo['grades']; ?>">
Room:<input type="text" size="8" name="room-<? echo $loop; ?>" id="room" value="<? echo $scheduleinfo['room']; ?>">
Notes:<input type="text" name="notes" id="notes-<? echo $loop; ?>" value="<? echo $scheduleinfo['notes']; ?>"><br />
<?
        }
?>
Contact: <? echo $venueinfo['$name']; ?><br />
Phone:<input type="text" size="15" name="phone" id="phone" value="<? echo $venueinfo['phone']; ?>"><br />
Email:<input type="text" size="25" name="email" id="email" value="<? echo $venueinfo['email']; ?>">
Event Notes: <input type="text" size="200" name="eventnotes" id="eventnotes">
<input name="submit" type="submit" value="Submit">
</form>

Thank you... worked great.

 

Can you possibly tell me what is wrong with the second half?

It says there is a parse error on 23

line 23 is if ($time) { ...

<?php
include_once("connect.php");

$eventid = mysql_real_escape_string($_POST['eventid']);
$address = mysql_real_escape_string($_POST['address']);
$city = mysql_real_escape_string($_POST['city']);
$state = mysql_real_escape_string($_POST['state']);
$zip = mysql_real_escape_string($_POST['zip']);
$directions = mysql_real_escape_string($_POST['directions']);
$eventnotes = mysql_real_escape_string($_POST['eventnotes']);

if($_POST['submit']){

$query = "UPDATE events SET address='$address', city='$city', state='$state', zip='$zip', directions='$directions', other='$eventnotes' WHERE eventid = '$eventid'";
$result = mysql_query($query)or die(mysql_error());
}

// insert schedule
$schedulequery = ("SELECT * FROM `schedule` WHERE eventid = '$eventid');
$scheduleresult=mysql_query($schedulequery);

for ($i = 1; $i <= 3; $i++) {
    $time = $_POST['time-' . $i];
    $grades = $_POST['grades-' . $i];
    $room = $_POST['room-' . $i];
    $notes = $_POST['notes-' . $i];
if ($time) {
    $scheduleinsert = "INSERT INTO schedules (eventid, time, grades, room, notes) VALUES ('$eventid', '$time', '$grades', '$room', '$notes')";
    $schedule_result=mysql_query($scheduleinsert);
    echo $time;
    }

}
?>

Thank You so much!

this

// insert schedule
$schedulequery = ("SELECT * FROM `schedule` WHERE eventid = '$eventid');

 

should be

 

// insert schedule
$schedulequery = ("SELECT * FROM `schedule` WHERE eventid = '$eventid'");

 

you forgot the quote

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.