Click here to Skip to main content
16,021,004 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
Questiondatetime.now Pin
Artakazezs12-Oct-09 2:46
Artakazezs12-Oct-09 2:46 
AnswerRe: datetime.now Pin
Luc Pattyn12-Oct-09 2:58
sitebuilderLuc Pattyn12-Oct-09 2:58 
AnswerRe: datetime.now Pin
EliottA12-Oct-09 3:54
EliottA12-Oct-09 3:54 
QuestionLittle help with my php code pls Pin
wartotojas11-Oct-09 2:34
wartotojas11-Oct-09 2:34 
AnswerRe: Little help with my php code pls Pin
fly90411-Oct-09 6:26
fly90411-Oct-09 6:26 
GeneralRe: Little help with my php code pls Pin
wartotojas11-Oct-09 9:54
wartotojas11-Oct-09 9:54 
GeneralRe: Little help with my php code pls Pin
fly90411-Oct-09 10:24
fly90411-Oct-09 10:24 
GeneralRe: Little help with my php code pls Pin
cjoki12-Oct-09 6:12
cjoki12-Oct-09 6:12 
I always include the form processing at the top to the same page and allow the logic to either load a successful registration page on success or reload the same page with errors marked in the form.

The general form is

<?php
	$name_good = true;
	if(isset($_POST['reg'])
	{
		if(isset($_POST['name']))
		{
			$name = htmlspecialchars($_POST['name'],ENT_QUOTES);
		}
		else
		{
			$name = "";
		}
		if(strlen($name)>0)
		{
			/* form data is valid, proceed */
			
			
			/* add code to check name in db */
				
			if( /* if name is not in use */)
			{
				/* record the name, then.... */
				header("location: http://www.sitename.com/welcome.php');
			}
			else
			{
				$name_good = false;
			}
		}
	}
	$pg = "<html>\n";
	$pg.= "<head>\n";
	$pg.= "	<title>Register</title>\n";
	$pg.= "</head>\n";
	$pg.= "<body>\n";
	$pg.= "<form action='' method='post'>\n";
	$pg.= "Name: <input type='text' name='name'";
	if($name_good)
	{
		$pg.= " class='field_good' title='enter your name' ";
	}
	else
	{
		$pg.= " class='field_bad' title='name is in use' ";
	}
	$pg.= ">\n";
	$pg.= "<input type='submit' name='reg' value='Join Now!'>\n";
	$pg.= "</form>\n";
	$pg.= "</body>\n";
	$pg.= "</html>\n";
	print $pg;
?>


I often leave the action empty as it will default to the same page.

Hope this helps
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 6:54
fly90412-Oct-09 6:54 
GeneralRe: Little help with my php code pls [modified] Pin
cjoki12-Oct-09 7:54
cjoki12-Oct-09 7:54 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 9:01
fly90412-Oct-09 9:01 
GeneralRe: Little help with my php code pls Pin
cjoki12-Oct-09 9:34
cjoki12-Oct-09 9:34 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 10:22
fly90412-Oct-09 10:22 
GeneralRe: Little help with my php code pls [modified] Pin
cjoki12-Oct-09 11:03
cjoki12-Oct-09 11:03 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 11:50
fly90412-Oct-09 11:50 
GeneralRe: Little help with my php code pls Pin
cjoki12-Oct-09 12:20
cjoki12-Oct-09 12:20 
GeneralRe: Little help with my php code pls Pin
fly90412-Oct-09 12:38
fly90412-Oct-09 12:38 
GeneralRe: Little help with my php code pls Pin
cjoki13-Oct-09 5:05
cjoki13-Oct-09 5:05 
Questioninstallation Pin
WilliamSimon8-Oct-09 12:07
WilliamSimon8-Oct-09 12:07 
Questioninstallation Pin
thangvel8-Oct-09 11:54
thangvel8-Oct-09 11:54 
AnswerRe: installation Pin
Richard MacCutchan14-Oct-09 6:07
mveRichard MacCutchan14-Oct-09 6:07 
AnswerRe: installation Pin
Iranian MM7-Sep-11 9:40
Iranian MM7-Sep-11 9:40 
Questiondownload php code Pin
udch7-Oct-09 1:24
udch7-Oct-09 1:24 
AnswerRe: download php code Pin
EliottA7-Oct-09 2:41
EliottA7-Oct-09 2:41 
QuestionI need some help Pin
robertbarzyk6-Oct-09 12:55
robertbarzyk6-Oct-09 12:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.