473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

i want to avoid blank entry and also after signup redirect to home page

hi am stuck with a signup form in which i want to avoid blank entry also i want the page to redirect to home page pls help am new to php
Expand|Select|Wrap|Line Numbers
  1. <?php    if(isset($_POST["submit"]))
  2. {
  3.  
  4.     if(($_POST['email']=='')  )
  5.     {
  6.         echo "Please enter email";
  7.     }
  8.     if(($_POST['name']=='') )
  9.     {
  10.         echo "Please enter name";
  11.     }
  12.     if(($_POST['password']=='') )
  13.     {
  14.         echo "Please enter password";
  15.     }
  16.         /*$email = "abc123@sdsd.com"; 
  17.         $regex = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/'; 
  18.         if (preg_match($regex, $email)) {
  19.          echo $email . " is a valid email. We can accept it.";
  20.         } else { 
  21.          echo $email . " is an invalid email. Please try again.";
  22.         } */
  23.  
  24.         $email = $_REQUEST['email'];    
  25.         $name = $_REQUEST['name'];
  26.         $password = $_REQUEST['password'];
  27.  
  28.         $query="Insert into users(email,name,password)values('$email','$name','$password')";
  29.         $res = mysql_query($query)or die(mysql_error());
  30.  
  31.  
  32.             if($res){    
  33.                 header("Location:index.php");
  34.                 exit;
  35.     }            else{
  36.             header("Location:signup.php");
  37.     }
  38.  
  39.     }
  40.             echo '<table border="2" padding="4">';
  41.             echo'<tr><td>User Registration:<form action="" method="post" ></td></tr></br>';
  42.             echo'<tr><td>E-mail:<input type="text" name="email" value=""/></td></tr>';
  43.             echo'<tr><td>Name:<input type="text" name="name" value=""/></td></tr>' ;
  44.             echo'<tr><td>password:<input type="password" name="password" value=""/></td></tr>' ;
  45.             echo'<tr><td><input type="submit" name="submit" value="submit"/></td>';
  46.             echo'</form>';
  47.             echo '</table>';
  48. include("footer.php");
  49. ?>
Oct 23 '13 #1
3 1368
Rabbit
12,516 Expert Mod 8TB
It looks like you already have code to check for blank entries and code for redirecting the page. I'm not sure what your question is.
Oct 23 '13 #2
hi its generating empty entries into my table(database user table) and also not redirecting to original ie index page
Oct 24 '13 #3
Rabbit
12,516 Expert Mod 8TB
1) It's generating blank rows because you don't stop the code from running if there are blanks.

2) It's not redirecting because you can't send headers after outputting data to the page. All headers must be sent before any other data is sent.
Oct 24 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Bruce A. Julseth | last post by:
I have a "new" homepage. How do I automatically direct clients to this new home page, i.e. when clients enter "OldHomePage.php", they will automatically be directed to "NewHomePage.php." ...
3
by: shank | last post by:
I have the following code to redirect users to http://www.mydomain.com/new/default.asp if they use the URL www.newstuff.com (sample). I have that domain name parked on www.mydomain.com. I'm getting...
8
by: Krul | last post by:
I like to have a blank entry at top of the combobox list, so the user is able to clear the combobox. Right now, the form displays a empty entry on load, but after chosen a value once, it is not...
1
by: IWP506 | last post by:
Hello I want to create a customizable home page. I'd like to be able to put together a template in frontpage, then put it on the web. I want to put in HTML comments like <!-- home page element...
1
by: steggun | last post by:
How can I always redirect any user to the "home" page? Basically, a user could enter a full URL in the address bar or bookmark a specific page so that they can go directly to that page. However,...
5
by: Steve B. | last post by:
Without adding whitespace to the ComboBox datasource is there a way I can add a blank entry or, a reset entry, to the ComboBox dropdown Thanks Steve
5
by: un1xg33k | last post by:
Hello, I'd like to find out if the following can be done. When someone comes to my site I would like to check to see if their homepage is set to my site. If it is then nothing is done. If it...
1
by: =?Utf-8?B?UmFq?= | last post by:
In MS home page, under "All Microsoft links", on clicking any one of the link a popup window displays. How excatly this is implemented if any one can let me know...I want to implement similar...
0
by: softfalls | last post by:
I need to build a home page in Flash which has multiple demos. I am fairly new to Flash so excuse me if this question sounds basic. I found a web design site that loads a tour demo when you click a...
2
by: amskape | last post by:
Hi pals, I have a problem regarding the page with listing. The listing page is arranged using pagination with 3 results per page. I need to delete each entry and redirect the page to proper...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.