Jump to content

Recommended Posts

ok guys so i have the events table up and it posts events just fine its getting late and im tired of looking at code ill do more tommorow

but the events script will actually post empty fields if you just hit submit so i was wondering

<form method="post" action="eventprocess.php">

      <table width="100%" cellspacing="0" cellpadding="0">

          <tr>

            <td width="59%">Convention ID Must Be Unique:</td>

            <td width="41%"><div align="center">

                <input type="text" name="id" size="20" value'This Must Be Changed'>

            </div></td>

          </tr>

          <tr>

            <td><font color="#008000">Start</font> Date/Time:YYYY-MM-DD 00:00:00</td>

            <td><div align="center">

                <input type="text" name="start" size="20">

            </div></td>

          </tr>

          <tr>

            <td><font color="#FF0000">End</font> Date/Time:YYYY-MM-DD 00:00:00</td>

            <td><div align="center">

                <input type="text" name="end" size="20">

            </div></td>

          </tr>

          <tr>

            <td>Event Type:</td>

            <td><div align="center">

                <input type="text" name="type" size="20">

            </div></td>

          </tr>

          <tr>

            <td>Event Location:</td>

            <td><div align="center">

                <input type="text" name="location" size="20">

            </div></td>

          </tr>

          <tr>

            <td>Event Details:</td>

            <td><div align="center">

                <input type="text" name="details" size="20">

            </div></td>

          </tr>

          <tr>

            <td>Event Notes:</td>

            <td><div align="center">

                <input type="text" name="notes" size="20">

            </div></td>

          </tr>

          <tr>

            <td colspan="2"><div align="center">

                <input type="submit" value="Submit New Event">

                <input type="hidden" name="action" value="submit_new_event">

            </div></td>

          </tr>

        </table>

    </form>

How Do you make it so you cant submit a empty field

could you do a function like " if all fields contain data then post else{you must fill out all fields}

 

This is the handler for posting data to database

$CONVENTION_ID = mysql_real_escape_string($_POST['id']);

$event_start = mysql_real_escape_string($_POST['start']);

$event_end = mysql_real_escape_string($_POST['end']);

$event_type = mysql_real_escape_string($_POST['type']);

$event_location = mysql_real_escape_string($_POST['location']);

$event_details = mysql_real_escape_string($_POST['details']);

$event_notes= mysql_real_escape_string($_POST['notes']);

 

 

mysql_query("INSERT INTO events

(CONVENTION_ID,event_start,event_end,event_type,event_location,event_details,event_notes) VALUES('$CONVENTION_ID','$event_start','$event_end','$event_type','$event_location','$event_details','$event_notes') ")

or die(mysql_error()); 

 

 

echo "Data Inserted!";

Link to comment
https://forums.phpfreaks.com/topic/125741-technical-question/
Share on other sites

You can check these field with javascript.  Have a function like:

 

function IsEmpty(aTextField) {
  if ((aTextField.value.length==0) ||
  (aTextField.value==null)) {
     return true;
  }
  else { return false; }
}

 

This help?

Link to comment
https://forums.phpfreaks.com/topic/125741-technical-question/#findComment-650210
Share on other sites

well i might not have to do this if i can figure out a way to delete a variable

i can do it with this

 

mysql_query("DELETE FROM events WHERE CONVENTION_ID= 'value' ");

 

But can you get it to work with this

$del_id = mysql_real_escape_string($_POST['delid']);

 

mysql_query("DELETE FROM events WHERE CONVENTION_ID=$del_id");

Where the red is input from the form with a input with name delid

Link to comment
https://forums.phpfreaks.com/topic/125741-technical-question/#findComment-650224
Share on other sites

By the way this goes to all that have helped me thank you so much I know im a noob im new to php but i am learning when this site is done and the hard work pays off you guys will be repayed for your troubles i wont forget the help

esspecially from f1fan who was helping me rather extensively on another problem

Link to comment
https://forums.phpfreaks.com/topic/125741-technical-question/#findComment-650227
Share on other sites

I always seperate the query. It makes it easier to debug:

<?php
$del_id = mysql_real_escape_string($_POST['delid']);
$query="DELETE FROM events WHERE CONVENTION_ID=$del_id";
mysql_query($query);

// you can now see what the query is doing by echoing it out:
echo $query
?>

 

Copy the query then try running it through phpMyAdmin to see what is going on.

 

You may find the error quicker.

Link to comment
https://forums.phpfreaks.com/topic/125741-technical-question/#findComment-650270
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.