Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Varibles, creating a table with form
Old 07-21-2008, 11:51 AM Varibles, creating a table with form
coldturkey's Avatar
Extreme Talker

Posts: 211
Name: Rachel
Location: Spain
Trades: 3
Hi,
I am adding an admin part to a site so the owner can add a new table for each property.
I have my form.... Very basic
Code:
<form action="createtable.php" method="post">
Name of house: <input type="text" name="name" size="20"> <input type="submit" name="submit" value="Submit"> </form>
and it should go to createtable.php... where the name of the property entered in the field in form comes out in this part
PHP Code:
<?php
$result
="CREATE TABLE This is where name of table should be(
proname varchar(100) NOT NULL,
prostart date NOT NULL,
proend date NOT NULL,
promin enum('Semana', 'Fin de Semana', 'Tres Dias') NOT NULL,
prostatus enum('Libre', 'Ocupado') NOT NULL
)"
;
But i cant get the name to come up there.... NO IDEA... I have tryed echo.. print... everything. Im not sure i am carrying the info from one page to the other corrently and Im not sure as it is in a 'result' varible that it will work that way... If I write it in manually there... the table is created.

Please help!!
Thanks
Rachel
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

coldturkey is offline
Reply With Quote
View Public Profile Visit coldturkey's homepage!
 
 
Register now for full access!
Old 07-22-2008, 12:07 AM Re: Varibles, creating a table with form
Super Talker

Posts: 116
Trades: 0
ok well since you put the input name="name", the variable you need would be $_POST['name']. i suggest changing it to something slightly more descriptive, like name="tablename", then you can use $_POST['tablename']

So this is what the could would look like:

PHP Code:
<?php
function sanitize($value) {
    
$value strip_tags($value);
    if(
get_magic_quotes_gpc()) {
          
$value stripslashes$value );
    }
    
//check if this function exists
    
if(function_exists("mysql_real_escape_string")) {
          
$value mysql_real_escape_string$value );
    }
    
//for PHP version < 4.3.0 use addslashes
    
else {
          
$value addslashes$value );
    }
    return 
$value;
}

$tablename sanitize($_POST['tablename']);

$query "CREATE TABLE $tablename (
proname varchar(100) NOT NULL,
prostart date NOT NULL,
proend date NOT NULL,
promin enum('Semana', 'Fin de Semana', 'Tres Dias') NOT NULL,
prostatus enum('Libre', 'Ocupado') NOT NULL
)"
;

$result mysql_query($query);
__________________


Please login or register to view this content. Registration is FREE

nasaboy007 is offline
Reply With Quote
View Public Profile Visit nasaboy007's homepage!
 
Reply     « Reply to Varibles, creating a table with form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14806 seconds with 12 queries