Jump to content


Photo

help with php screens


  • Please log in to reply
4 replies to this topic

#1 rsammy

rsammy
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 14 August 2006 - 10:44 PM

guyz,

i have a screen with some fields like first name, middle initial, last name, address, city, state, zip, phone number, date of birth, ssn.

user populates these fields with some values. i need to store these values in the database. (insert into a table, say patient table in MySQL database) when user clicks on Add button on screen. On clicking Add, a new screen appears displaying all the above fields as Text only fields(cannot be edited) with a text saying the following patient has been added!

while entering the values in the fields, if user enters  the name as john smith, it should be displayed on the screen as John Smith and entered into the db as such. i know there is a function called onBlur and i have a fucntion written for it too. but, it doesnt work! ???

I know its a simple app. but, i am kinda new to php and am still findin it difficult to go about this one. i need help big time. any help here would appreciated greatly.

thanks in advance.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 14 August 2006 - 11:04 PM

Here's a sample snippet

<?php
if (isset($_GET['submit'])) {
	$name = ucwords($_GET['name']);
	
	echo "Name : $name";
	
	mysql_query("INSERT INTO patients (name) VALUES ('$name')") or die(mysql_error());
}
?>

<FORM>
<input type="text" name="name" size="30">
<input type="submit" name="submit" value="Submit">
</FORM>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 rsammy

rsammy
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 15 August 2006 - 07:22 PM

thanks. but, itd be great if u can be a lil more specific. im a novice in php!  i really appreciate ur quick response tho!

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 15 August 2006 - 07:39 PM

A simple form with a name input field and a submit button. The default form method is GET and the default action it to call the sames page

<FORM>
<input type="text" name="name" size="30">
<input type="submit" name="submit" value="Submit">
</FORM>

Processing

<?php
//
//  check if data has been sent to the page
//
if (isset($_GET['submit'])) {
	
	//
	//   make first letter of each word upper case (http://www.php.net/ucwords)
	//
	$name = ucwords($_GET['name']);
	
	//
	// echo the name eg John Smith
	//
	echo "Name : $name";
	
	//
	// update the database inserting a new record with eg  name = John Smith
	//
	mysql_query("INSERT INTO patients (name) VALUES ('$name')") or die(mysql_error());
}
?>

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 rsammy

rsammy
  • Members
  • PipPipPip
  • Advanced Member
  • 212 posts

Posted 17 August 2006 - 09:07 PM

A simple form with a name input field and a submit button. The default form method is GET and the default action it to call the sames page

<FORM>
<input type="text" name="name" size="30">
<input type="submit" name="submit" value="Submit">
</FORM>

Processing

<?php
//
//  check if data has been sent to the page
//
if (isset($_GET['submit'])) {
	
	//
	//   make first letter of each word upper case (http://www.php.net/ucwords)
	//
	$name = ucwords($_GET['name']);
	
	//
	// echo the name eg John Smith
	//
	echo "Name : $name";
	
	//
	// update the database inserting a new record with eg  name = John Smith
	//
	mysql_query("INSERT INTO patients (name) VALUES ('$name')") or die(mysql_error());
}
?>


great! got it. thanx for ur help!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users