Jul 26, 2008

Making Sure They Did Not Leave Any Required Fields Blank

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming

free web hosting

Making Sure They Did Not Leave Any Required Fields Blank

dvayne
how to make sure they did not leave any required fields blank?
CODE
<?php
    include("config/config.inc.php");
    include("config/dbcon.php");
    include("checksession.php");
    
        if(isset($_POST['action'])){
        $gname = $_POST['gname'];
        $gemail = $_POST['mail'];
        $gmsg = $_POST['gmsg'];
        $date = date("m.d.y");
$sql = "insert into tblguestbook ";
$sql .= "(guestname, guestemail, guestmessage, guestdate)";
$sql .=" values('$gname','$gemail','$gmsg','$date')";
    mysql_query($sql);
    }

?>


<html>
<head><title>My Guestbook</title>
<link href="styles/style.css" rel="stylesheet" />
<script language="javascript" src="includes/validate.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
    background-color: #000000;
}
-->
</style></head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="17%">&nbsp;</td>
    <td width="83%" valign="bottom" >&nbsp;</td>
  </tr>
</table>

<form name = "form1" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" onSubmit="return validateForm(form1)">
  <p class="fontSubTitle">Sign to Guestbook</p>
  <p class="fontSubTitle"><span class="fontText">Name: </span>
    <input type="text" name="gname">
    <br>
    <span class="fontText">Email:</span>
    <input name="mail" type="text" id="mail">
    <br>
    <span class="fontText">Message:</span>
    <textarea cols="35" rows="6" name="gmsg"></textarea>
  </p>
  <p class="fontSubTitle">
    <input type="submit" value="Send" name="action">
    <input name="reset" type="reset" value="Clear">
    <br>
  </p>
</form>
  <p>
    <?php
    $results = mysql_query("select * from tblguestbook order by guestid desc");

    while($data = mysql_fetch_object($results)){
    echo "<table width=\"500\" border=\"0\" cellpadding=\"5\" cellspacing=\"1\" class=\"borderThin\" >";
echo " <tr>\n";
echo "<td class=\"fontTextTwo\" align=\"left\" width=\"60%\">name: ";
echo "<a href=\"mailto:".$data->guestemail."\" class=\"b\">".$data->guestname."</a>";
echo "</td>\n";
            echo "<td class=\"fontTextTwo\" align=\"right\"  width=\"40%\">dated posted: ".$data->guestdate."</td>\n";
echo "  </tr>\n";
          echo "<tr>\n";
           echo " <td colspan=\"2\" class=\"fontText\" align=\"left\">".$data->guestmessage."</td>\n";
echo " </tr>\n";
echo "</table><br>";
    }
    
?>
</p>

</body>
</html>
<?php
    mysql_close($dbh);
?>

any help would be appreciated.

 

 

 


Reply

pop
If you want to check that something isn't empty use operator == .
Let's say you want to check your post['name'] to be empty, you can use

CODE
if (post['name'] !== "")


In this case if condition will only return true if post['name'] !== ""

Also you can use empty

CODE
if (!empty(post['name']) {


Will return true if your post['name'] is everything but empty.

To check your post['name'] even better, you can use regular expression

CODE
$pattern = '/[^a-z]/i';
if(preg_match($pattern, $string)>0) {


returns true if there was some other character than letter

Reply

gogoily
I add one tips:

CODE
if(preg_match("/^\s*$/",$string))
{
    die("Sorry, but all fileds must be filled !");
}


This code can prevent any kind of blank, including spacing.

Reply

online
for examle... (i make this simple)
CODE
<?php
if($_GET['act'] == 'fields')
{
echo "<br><b>Please fill in all the fields.</b><br>";
}

if($message == '')
{
header("location:?do=&act=fields");
exit;
}
?>

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : making, leave, required, fields, blank

  1. How Would I Go About Making A Simple "counting" Script?
    (3)
  2. Script Help Required: Undefined Variable
    A fault I cannot spot in PHP (3)
    Hi, when running a PHP script I keep getting the error: QUOTE Notice: Undefined variable: bret
    in c:\program files\easyphp1-8\home\poll.php on line 294 Notice: Undefined
    variable: bret in c:\program files\easyphp1-8\home\poll.php on line 294 (And,
    yes, I get it twice). The code related to the variable is as follows: CODE function
    LogString($string,$type)     {         $t_log = "\n";
            $t_log .=
    $this->globaldata->server_vars['REMOTE_ADDR']."....
  3. [php] Hidden Fields?
    (4)
    well what is hidden fields for.. i see alot of em in sources... what purpose do they server? how
    to use em? etc? well can any one help me out here =?....
  4. Blank Cookies...
    Need some help with Cookies... (4)
    Hi. I'm doing a website that basically checks if it has chosen a css style before. If it has, it
    shows the last shown style, and if it doesn't, it shows "natura" style. On the page there's
    a form that lets the user choose the style. It is based on cookies. The thing is that when I do java
    script:alert(document.cookie) on the address bar it gives me a blank alert! And, obviously, when
    I reload the page, the style doesn't change!!! The thing is I'm sure it has
    nothing to do with the HTML code, and I also thing it does have nothing to do ....
  5. What Coding Languages Are Required?
    (5)
    I want to add a feature in my website so that users can make a professional -looking resume-like web
    page. It will be like a form based series of questions that visitor ll need to answer.Based on this
    a webpage as prescribed in pre-defined template ll be created .I want to know to do this what
    languages are used? I want some suggestion regarding this.My site is currently on Joomla platform.
    thanks in advance....
  6. Blank/duplicate Entries
    a little help please. (5)
    Hi, I have been working with a download/link exchange script:
    http://evilddl.info/download/EViLDDL_1.0.1.rar However it has some problems when adding download
    links.. Users can submit downloads with no title, and also entries with duplicate titles. Can
    anyone show me how to fix this?? Here is the submit page: "> "> ">


    Menu ....
  7. How To Delete A Row In Mysql.
    A very simple help required (4)
    Im using the following code, for very simple work.. it simply gets and print the comments which are
    stored in the database. Now it will show like comment 1. comment 2. comment 3. etc etc i want to
    add 'delete' option that i can delete any comment. it displays like comment 1.
    Delete comment 2. Delete comment 3. Delete
    So that when i click on delete, it simply deletes the comment and print the remaining comments. Its
    very simple. i hope you understand. QUOTE $result = mysql_query("sele....
  8. Making This Compatable With Trap17's Php
    (2)
    ok, i have a php script that is not compatable with trap17's php (4.4.4) i believe it was made
    to run on php 5, if anyone could help, id really appreciate it, thanks /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> function
    something($info) { $script = new mirc_script($info); $script->highlight();
    return $script->get_script(); } class mirc_script { private $data = array(); public
    $chars = array(); // By specifying TRUE for $beautify here you can save a bit a
    processing time rather....
  9. Making A New Bbcode For Smf 1.09
    (0)
    Im using SMF version 1.09 i would like to make a bbcode so that it shows mirc syntax highlighting
    (as i have an mirc based site) i have a php script that will do the highlighting, im just really
    not sure how to incoporate that with the forum. http://www.mirc.net/tye/mirc_script.phps is the
    link for the script, it is not mine, but made by tye of mirc.net thanks for the help. Ive asked on
    the simple machines forum but theres been absolutely no help, so if anyone here can help me out, id
    really appreciate it.....
  10. Making A Sig With Php
    just wondering how it works (7)
    I was just wondering how to make an image that uses stuff given to it by php, yet remains only an
    image - say I want the site's title in an image. I believe it has something to do with putting
    an index.php inside a folder called image.png or whatever. Am I right? thanks....
  11. Files Required?
    (5)
    I want to learn php and I am already on the first steps to doing it. I have set up my server using
    easyPHP as well as XAMPP which is a package containing FileZilla, Apache and MySQL. Other than
    easyPHP, XAMPP and MySQL, what other softwares are required to be set up for me to successfully
    learn how to program with PHP?....
  12. Php Code Fix Required
    URGENT (3)
    I am running a Web Chat and need to get this to display the User IP to them, but this code isnt
    working. CODE <PARAM NAME="welcomemessage" VALUE="<?php
    echo  $_SERVER['REMOTE_SERVER'];" has been logged. Chat powered by
    GCN"> Any help would be extremly grateful. Thank you Inserted the code in CODES tag ....
  13. Some Php Functions Explaination Required
    (2)
    Can some one please tell me what is the purpose of the following functions , although there's a
    little explaination with everyline but i cant understand, can some one exaplin it bit clearly and
    tell me that why it is needed in config.inc.php.. what is its purpose and will it work if i dont
    include these files in config.inc.php thanks QUOTE ### Url were Website has been installed, not
    '/' in end! define('C_URL','http://www.test.com/Website'); ### Internal
    path to Website directory define('C_PATH','Z:/home/www.test.com/www/....
  14. How To Make Oscommerce Work With Phpbb
    making oscommerce work with phpbb (1)
    i'd like to make oscommerce work with phpbb.imean that any person register to phpbb is
    automatically regitered to oscommerce and vice versa. if you have any advice or idea that may help
    plz send it.(any help would be appricated)....
  15. Intranet Search Engine
    Need help in making one! (4)
    Hmm.. I am assigned a work of doing a project in PHP to build a intranet search engine. Can any
    body help? Moving from Introductions to PHP Programming. Also edited the topic title &
    description. Please be more descriptive in title & description. And it will be nice if you can be
    more descriptive in your posts ....
  16. Blocking Pages & Making Ranks
    (4)
    I would like to know how and where to put the code that would block certain pages so people could
    only get to them if they logged in. And I would like to have ranks on the site and when you get to a
    certain rank you get more options like being able to add members and stuff. And also. I would like
    some code for a news sytem for the homepage. Like where you have to be logged in to post something
    and only people with certain ranks will have access to it and only certain people can delete it. I
    would like to be able to make it so on the members page it displays members and y....
  17. Personal Blog
    [ Database Required ] (4)
    Okay, after a week, I have successfully created a personal web blog. I first created it using a flat
    text file, I but realized that it was just too limited like that. So, I redid it in a
    database-compatible manner. NOTES: CODE - This blog does not support comments yet. If you
    want, you can build  on this script by creating a comment system as well. I may also    update it
    with a comment system in the future. - You should have an average to intermediate knowledge of
    MySQL    commands and database manipulation in general, especially if you    want to add a ....
  18. Chatbox / Guestbook
    No Database required (2)
    Okay, this is a simple script that lets your visitors enter in messages via a chatbox/guestbook. You
    can use this how you like. Adjust it if need be. It's very simple, so there is much room for
    improvement. Enjoy! CODE echo "<form action='chatbox.php'
    method='get'>"; echo "Name: <input type='text'
    name='visName' size=15><br>"; echo "Message: <input
    type='text' name='message' size = 15><br>"; echo "<input
    type='submit' value....
  19. Php Shows Blank Page
    (1)
    Hey there everyone, I'm trying to create a website using some PHP. I created an order form for
    my school company to let people order products this way. Only orders are made - no payments or
    anything. Now I have create the whole website. It is very simple. Every different product has a
    different combobox to select the number of items from. Then on the end of the page the client's
    details are asked. Now I created this PHP file that would handle everything, that is collecting all
    information and creating a well-formatted e-mail to send to the company's e-mail a....

    1. Looking for making, leave, required, fields, blank

Searching Video's for making, leave, required, fields, blank
advertisement



Making Sure They Did Not Leave Any Required Fields Blank



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE