Jump to content

this code was given to me, How can I remove the field verification?


aaricwon

Recommended Posts

Someone gave me this code. It works fine but it won't let me submit the form if ALL of the fields aren't filled out. I don't want that. I want to be able to leave some fields blank sometimes. I tried removing some code myself but when I did it, I'd get an error...

 

<script language="javascript" type="text/javascript" src="jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode : "textareas"
});
</script>
<?php
if (isset($_POST['submitted'])) {
include ('mysql_connect.php');
if (empty($_POST['title'])) {
echo '<p><font color="red">You need to enter a title fuckface!.</font></p>';
} else {
$title = $_POST['title'];
}

if (empty($_POST['name'])) {
echo '<p><font color="red"><b>You need to enter a name!</b><p>In your case I suggest using IDIOT! .</font></p>';
} else {
$name = $_POST['name'];
}

if (empty($_POST['message'])) {
echo '<p><font color="red">You need to enter a message! Damnit!</font></p>';
} else {
$message = $_POST['message'];
}

if ($title && $name && $message && $full) {
$query = "INSERT INTO news_posts (title, author, post, full, date) VALUES ('$title', '$name', '$message', '$full', NOW())";
$result = @mysql_query($query);

if ($result) {
echo '<p><font color="red">News was added!</font></p>';
} else {
echo '<font color="red"><p>News could not be added! Please try again.</p></font>';
}
} else {
echo '<p><font color="red">Please fill in the appropriate information</font></p>';
}}
?>
<link href="../../CSS/a_tag_effects.css" rel="stylesheet" type="text/css">
<link href="../../CSS/Level2_Arial_Text.css" rel="stylesheet" type="text/css">

<style type="text/css">
<!--
.style1 {
color: #FFFFFF;
font-weight: bold;
font-family: Arial, Helvetica, sans-serif;
}
.style2 {
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
font-size: 12px;
}
-->
</style><div style="border : solid 1px #000000; background: #DFE8FB; width : 458px">
<table width="450" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="left" valign="top" bgcolor="6698CB"><span class="style1">ASC Daily Log v1.0 </span></td>
  </tr>
  <tr>
    <td width="450" align="left" valign="top"><div style="border : solid 0px #000000; background: #DFE8FB; width : 458px">
      <form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
        <span class="style2">Oracle Order :</span><br />
<input type="input" name="title" size="25" maxlength="60" value="<?php if(isset($_POST['title'])) echo $_POST['title']; ?>" /></p>

<p><span class="style2">Method :</span><br />
<input type="input" name="name" size="15" maxlength="35" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" /></p>
<p><span class="style2">Notes:</span><br />

<textarea rows="5" cols="54" name="message"><?php if(isset($_POST['message'])) echo $_POST['message']; ?></textarea>
<br>
<span class="style2">Additional Notes:</span><br>
<textarea rows="8" cols="54" name="full"><?php if(isset($_POST['full'])) echo $_POST['full']; ?>
</textarea>
<input type="hidden" name="submitted" value="TRUE" />
  <input type="submit" name="submit" value="Add to Log" />
  <input type="reset" name="Reset" value="Clear">

</p>
      </form></div>
    </td>
  </tr>
</table></div>
[code]

[/code]

Link to comment
Share on other sites

which fields would you like to keep empty?

 

just remove the entire If statement, like so:

 

this:

if (empty($_POST['title'])) {
echo '<p><font color="red">You need to enter a title fuckface!.</font></p>';
} else {
$title = $_POST['title'];
}

 

becomes:

$title = $_POST['title'];

 

 

hope this helps,

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.