crud for newbie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
macario1983
Forum Newbie
Posts: 6
Joined: Fri Aug 17, 2012 5:22 pm

crud for newbie

Post by macario1983 »

hi, i need a help urgent because monday i´m going to have a job test

i need to know how make a crud system

i don´t know if i´m going right if someone can help me its gonna be ok

i´ve created various files php...

1 to make conection with, 1 to insert, 1 to edit, 1 to delete, 1 to show the register and 1 to be my input form

So i imagined to put in my form and call the file of form and file of insert to insert

And this going....to the rest

I´m doing the right?

Thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: crud for newbie

Post by requinix »

Not quite sure what you're asking for, but

A typical CRUD system works like:

Code: Select all

Index page
--> [R]ead a particular record
    --> [U]pdate the record
    --> [D]elete the record
--> [C]reate a new record
As long as you have those four mechanisms the system counts as CRUDy. Whatever the code actually looks like, whatever the various PHP files look like.
macario1983
Forum Newbie
Posts: 6
Joined: Fri Aug 17, 2012 5:22 pm

Re: crud for newbie

Post by macario1983 »

requinix wrote:Not quite sure what you're asking for, but

A typical CRUD system works like:

Code: Select all

Index page
--> [R]ead a particular record
    --> [U]pdate the record
    --> [D]elete the record
--> [C]reate a new record
As long as you have those four mechanisms the system counts as CRUDy. Whatever the code actually looks like, whatever the various PHP files look like.

my doubt is about how can i use make my system

because i create 3 files, each one to insert, update and delete

so insert and update can use the same form no?
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: crud for newbie

Post by califdon »

How you combine or do not combine functionality in script files is beyond the concept of CRUD. Yes, often some or all of those functions can be combined in a single file, using the response of the user to determine which section of code is executed, but that is a matter of choice for the developer, it doesn't change the concept of CRUD in any way, as long as those 4 capabilities are present.
macario1983
Forum Newbie
Posts: 6
Joined: Fri Aug 17, 2012 5:22 pm

Re: crud for newbie

Post by macario1983 »

i´ve found yesterday on google one code and made my code like that

Code: Select all

<form method="post" >
	<fieldset>
	<legend>Formulário de Cadastrado</legend>
		<label>Nome: <input type="text" name="nome" /></label>
		<label>Email: <input type="text" name="email"/></label>
		<label>Telefone: <input type="text" name="telefone"/></label>
		<input type="reset" value="Limpar" />
		<input type="submit" value="Enviar" />
		<input type='hidden' value='1' name='enviado' />
	</fieldset>
</form>

<?php

	include('configuracao.php');
	
	if(isset($_POST['enviado'])){
		
		$sql = "INSERT INTO contato (nome,email,telefone) 
				VALUES ('$_POST[nome]','$_POST[email]','$_POST[telefone]')";
		
		mysql_query($sql);
	
	}
	
?>
I want to know if there is better way or i´m corret

For edit and delete i´ve imagine to make the same thing putting a radio with every register...

What do you think?

Thanks to everyone
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: crud for newbie

Post by califdon »

Does it work properly?
macario1983
Forum Newbie
Posts: 6
Joined: Fri Aug 17, 2012 5:22 pm

Re: crud for newbie

Post by macario1983 »

califdon wrote:Does it work properly?
i didn´t terminated my job because i have other problem that i opened other post to people help me...

but i hope to end this today
Post Reply