Results 1 to 4 of 4

Thread: Problem in PHP form

  1. #1
    Join Date
    Apr 2009
    Posts
    6

    Problem in PHP form

    I have created a form that sends data in my database sql. Thats goes well only if the fields are empty, data is transmitted in the base. I try to use the empty but it not work, My friend told me to use the trim but that also didn't work.

    Can someone help me ?

    Thanks

  2. #2
    Join Date
    May 2008
    Posts
    29

    Re: Problem in PHP form

    Surely we will help you can you post your coding ? So that we will come to know your coding is correct or not.

  3. #3
    Join Date
    Apr 2009
    Posts
    6

    Re: Problem in PHP form

    Sorry i forget to post code.

    Code:
    <? php 
    
    mysql_connect ( "localhost", "root", "") OR die ( 'Error selecting database'); 
    mysql_select_db ( "camping") or die ( 'Error selecting database'); 
    / / (=> Useless 
    
    $ name = $ _POST [ 'name']; 
    $ first_name = $ _POST [ 'firstname']; 
    $ address = $ _POST [ 'address']; 
    $ PostalCode = $ _POST [ 'PostalCode']; 
    $ city = $ _POST [ 'city']; 
    $ telephone = $ _POST [ 'telephone']; 
    $ mail = $ _POST [ 'mail']; 
    $ message = $ _POST [ 'message']; 
    
    if (empty ($ name) & & ($ firstname) & & empty ($ address) & & empty ($ PostalCode) & & empty ($ city) & & empty ($ telephone) & & empty ($ mail) & & empty ($ message)) 
    ( 
    echo ( "There is an empty field"); 
    ) else 
    ( 
    echo ( "fields filled"); 
    
    )
    
    $ req = mysql_query ( 'INSERT INTO clients (name, surname, address, Postcode, city, telephone, mail, message) VALUES ("'.$ name.' "" '. $ firstname.' "" '. $ address. ' ""'. $ PostalCode. ' ""'. $ city. ' ""'. $ telephone. ' ""'. $ mail. ' ""'. $ message. ") ') or die (mysql_error ()); 
    if ($ req) 
    ( 
    echo 'enregisttrement reussi'; 
    ) 
    else 
    ( 
    echo 'There was a problem <br/>. $ req; 
    ) 
    
    
    
    mysql_close (); 
    >

  4. #4
    Join Date
    May 2008
    Posts
    29

    Re: Problem in PHP form

    function empty () "is very applicable. your problem that the instruction "INSERT" must be executed in the instruction "else" because your code following the instruction "INSERT" is executed as it is found outside the instruction "else" .

Similar Threads

  1. Replies: 5
    Last Post: 25-05-2011, 10:21 PM
  2. Replies: 2
    Last Post: 02-05-2011, 07:06 AM
  3. Problem in form submission
    By Udyan in forum Software Development
    Replies: 4
    Last Post: 30-01-2010, 04:28 PM
  4. Problem of form that sends a get instead of post
    By HarshaB in forum Software Development
    Replies: 3
    Last Post: 14-10-2009, 10:26 PM
  5. Problem reloading MDI child form in main form.
    By AFFAN in forum Software Development
    Replies: 3
    Last Post: 30-01-2009, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,752,102,206.57268 seconds with 16 queries