Jul 27, 2008

Alter Sql Table With Php File - how to?

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > PHP Programming
Pages: 1, 2

free web hosting

Alter Sql Table With Php File - how to?

hype
How do I make a code such that it shows a input box that will be inserted into the certain field and database of a specific database?

Like how do I make a field like in this forum like the textbox of the topic title.

Lets say I wanted a user to input his friend email, then how do I create it so that the info will go to my database?

Reply

HmmZ
well first, you need to connect to mysql and make your way to your DB
CODE

$conn=mysql_connect('localhost','username','password');
$db=mysql_select_db("dbname",$conn);
if(!conn){
die("could not connect to server.."); }
if(!db){
die("could not connect to database.."); }


then make a form code and complete your script:
CODE
<form method=post action='thispage.php?insert=yes'>
insert into table: <input type='text' name='insert' size=30>
<input type=submit value=submit name='go'>

$insert=$_GET['insert'];
if($insert=yes){ mysql_query("INSERT field into table VALUES('')"); }


it should be something similar to that..

 

 

 


Reply

hype
thanx...

Just a stupid question, I need to close the form right?

Reply

hype
It doesnt really works...

ok, lets say I want to put in the following field

comment
rating(option form)

and I also want the it to remember the userid that enter the field so that I can set it like only the user can edit the field. So how do I do that? blink.gif

Thanx in advance...

Reply

HmmZ
Sorry for the non-working script sad.gif

CODE

<form method=post action='submit.php'>
$user=$_SESSION['username']
//the session name of $user (in brackets) has to correspond with the $_SESSION[''] you
//are using for your user(login)
$userid=mysql_query("SELECT userid from usertable where username='$user'")
//adjust tablename to correspond with your usertable
Your comment: <input type='textarea' name='comment' cols='30' rows='10'>
Your rating: <select name='rating'><option value='0'>NONE</option><option value='10'>10</option><option value='9'>9</option><option value='8'>8</option><option value='7'>7</option><option value='6'>6</option><option value='5'>5</option><option value='4'>4</option><option value='3'>3</option><option value='2'>2</option><option value='1'>1</option></select>
<input type='hidden' name='userid' value=$userid>
<input type=submit value=submit name='go'>


then just make a new page called submit.php
for this page you need to insert a field in your 'comment/rating' table with something like author
CODE

<?php
$comment=$_POST['comment'];
$rating=$_POST['rating'];
$author=$_GET['userid'];
if(!$user || !$userid){
die("A problem occured when connecting to the database");
if(empty($comment) {
echo "Please write your comment";
}
if($rating==0){
echo "Please give a rating";
}} else {
mysql_query("INSERT INTO commenttable VALUES('$comment','$rating','$author')") or die("A problem occured when trying to post your comment");
}


Hope this helps..

Reply

hype
Thank you +1 rep biggrin.gif

Just a follow-up question, how do you make something that could check a input value whether if its a number the the script will allows it to pass through the checker, and how do I make a checker that doesnt allows ppl to put html tags or codes into the input?

Reply

HmmZ
you mean like with ratings? It's all done through if() statements, if you want to put an if() on a value (for example with the ratings), it's something like this:

CODE
if($rating['X'] { }


wich means that if the variable $rating gets the property value of X (NONE-10) it will whatever you specify.

Hope that helps

Reply

hype
No, I dont mean rating...

What I means is like what I'm typing into now, a textarea, and they have something that filter out all html tag like / <a href= and many others, so how do make this filter?

And how do I make a textbox that doesnt allows any character except numbers?

Reply

HmmZ
well i think the following could work:
CODE

<textarea name=$textarea cols='10' rows='30'></textarea>
$textarea=htmlspecialchars($textarea,ENT_QUOTES);
$textarea=StrReplace($textarea,'<','>');
$textarea=StripSlashes($textarea);


That kind of stuff is normally used for SQL Injection prevention, but it should strip all the < and >, wich are the characters needed to get html going..

Reply

HmmZ
Sorry for the double post, i didnt know what to do with "numbers-only textbox", googled and the only possible way is javascript:
CODE
<script language="javascript" type="text/javascript">
<!--
function intOnly(i) {
if(i.value.length>0) {
 i.value = i.value.replace(/[^\d]+/g, '');
}
}
//-->
</script>

Integer Only Textbox:<br>
<input type="text" onChange="intOnly(this);"
onKeyUp="intOnly(this);" onKeyPress="intOnly(this);">

Source: Evoluted.net

Reply

Latest Entries

hype
I want to make like the forum where post are being filter and html tags will be change to &#46; and show on the browser instead of the normal sign...

Reply

HmmZ
The code i gave you should disable the use of ['s and ]'s, wich are the tags needed for html, people won't be able to insert html, because they will then show as plain text, you can't disable all characters used inside of html tags, as this would cause a great disability to your textarea..

Reply

Tyssen
QUOTE(hype @ Jun 11 2005, 04:25 PM)
It gives me something like (/[^0-9]+/) or some else

That's called a regular expression. I don't know much about regular expressions but if you Google it you should come up with something useful.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Pages: 1, 2
Similar Topics

Keywords : alter, sql, table, php, file

  1. Internal File Transfer
    (5)
  2. Free Software For File Recovery
    RECUVA (3)
    Hi all, I was loking for a software to recover my lost files and I found this /biggrin.gif"
    style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> And the best part is ,
    its free Recuva - File Recovery Recuva (pronounced "recover") is a freeware Windows utility to
    restore files that have been accidentally deleted from your computer. This includes files emptied
    from the Recycle bin as well as images and other files that have been deleted by user error from
    digital camera memory cards or MP3 players. It will even bring back files that have been d....
  3. Where Is The Bookmarks File Stored With Ff2?
    (4)
    My bookmarks are critical and lengthy. I'd like to save them to a flash drive, since my laptop
    is ancient and it's been acting up lately. I went into the FireFox folder, but couldn't find
    the bookmarks info anywhere. there's a bookmarks.html page, but it doesn't contain the
    actual bookmarks. Where does FF2 store the bookmarks? Or is there an easier way to copy and paste
    the bookmarks to another file? /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0"
    alt="huh.gif" /> 2 poor 4 a sig ....
  4. Debug Exe Files
    How to debug an exe file. (4)
    Think that we have written a program, and some codes are wrong. We can go back to compiler and
    change the code, and compile again. But I will show you how to correct our mistakes without using
    the compiler. Let's start: I have written a program in Delphi. Let's see my mistake. I
    have created a form like this. After this I wrote the codes in the Compare Button click as
    below. CODE 1.   procedure TForm1.ComparebuttonClick(Sender: TObject); 2.   var
    3.     a,b:integer; 4.   begin 5.     a := StrToInt(EditA.Text); 6.     b :....
  5. Create Table - Mysql Code - Help
    (1)
    I need your feedback about setting the database issues. Please, review them and correct some entries
    in the code if they got some mistakes. This is the code itself: SQL CREATE TABLE
    `news` ( `id` int(250) NOT NULL auto_increment, `title` varchar(255)
    NOT NULL default '', `text` text NOT NULL, `author` varchar(255) NOT
    NULL default '', `valid` varchar(255) NOT NULL default '',
    `date` varchar(255) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE = ....
  6. File Manager Not Working
    (2)
    When I goto upload files using the file manager(legacy mode), the files do not upload correctly.
    Every time I try to upload a file, it takes the time to upload it, but the file always comes out
    being 0kb so it does not upload the file. Why is this happening?....
  7. A Good File Explorer For Windows Xp?
    what's a better alternative to explorer (6)
    Hi, although it has some useful features and it's (i'd hope so...) well integrated with the
    shell, the file explorer that comes with windows xp is not the best we can ask for... so I've
    always tried to use various other pieces of softwares randomly found on the net whenever I've
    had to intensively work on my file directory... still I haven't found a very good one, all
    those I tried have some kind of bug or they are not really user friendly in some occasions... would
    anyone suggest a good FREEWARE file explorer? thanks /wink.gif" style="vertical-al....
  8. Defraggler - Free Software To Defrag Your File
    Try it out (12)
    Have you all hear a software called Defraggler? Well if not, I recommend you to download this
    software. What does it do? Simple, it'll quickly defrag files you want to defrag, no need to
    defrag the whole drive. Useful if you have less fragmented file and if you hate Windows's
    original defragger. And it's free! OS Supported and filesystem supported? All Windows 2000
    or higher (it'll be Windows 2000, 2003, XP and Vista. 64-bit support too) It support NFTS and
    FAT32 Requirement? Well not much, the EXE file even smaller than 1 MB (dont judge the power ....
  9. Qoodaa Successfully Solved Video Downloading Problems
    a good large file transfer tool, (0)
    The rise of Video web stimulates more intuitive video feeling of large people, and makes video
    downloading become a popular trend in web times. Meanwhile, more and more downloading problems arise
    correspondingly, in which the first trouble is slow downloading speed and incomplete downloading. It
    seems to many people that downloading video, especially downloading large video, is like a
    protracted war with the internet, even the victory is difficult to predict. Many domestic video web
    has succesesfully solved downloading problems that they suffered for a long time, after....
  10. Share Qoodaa
    a good large file transfer tool, (0)
    Knowing Qoodaa was quite by chance. A few days ago, my friends studying in America recommended me a
    new popular transfer tool—Qoodaa. And he told me that it was a quite good software to download
    files and movies. At first,I was skeptical, but after using it, I found it’s a good choice to
    choose Qoodaa. And I have summarized the some features of Qoodaa: 1.Its speed is faster than any
    other softwares I used before to upload movies. 2.It can download files quickly through downloading
    links, in a word, it is time-saver and with high efficiency. 3.No limit of spac....
  11. Issues Uploading A File [resolved]
    (3)
    Hi there. I have been trying to upload a zip file only about 2mb to my account through CPanel.
    First I tried uploading it to a new folder in public_ftp. Then i tried to put it in the main part
    of public_ftp. I also tried the same thing in public_html. It shows the file being uploaded, and i
    get 100 %, but alas, when i look in the folders nothing is there. Is there a restriction on .zip
    files? I have had no problems as of yet uploading htm and html pages. Please let me know ASAP.
    Thank you.....
  12. Make A Moderately-secure Password System Using Javascript
    using file redirection to hide the password. (4)
    JavaScript is very handy at making forms, allowing for much more customization and easier ways to
    send data. So making Login forms using JavaScript may seem to many to be a very feasable idea.
    However, JavaScript is very bad at protecting Passwords, as since the passwords are not encypted and
    the whole JavaScript code is in the page, a person could just view the Page Source and find out
    everything. Even if you use an external JavaScript, it would still be poor as the file name for the
    external JavaScript would still be revealed. But I have an answer! There is a rela....
  13. Php Configuration File
    "config.php" (16)
    I did create this topic mainly because I want to know everything about that configuration file. I
    will post other replies if I want to know more depending on your experience. Is this code correct
    for that file: CODE <? $host="localhost"; $dbname="XXX";
    $dbuser="XXX"; $dbpass="XXX";
    $connection=mysql_connect($host, $dbuser, $dbpass) or
    die(mysql_error()); mysql_select_db($dbname) or
    die(mysql_error()); ?> Add your suggestions or i....
  14. Question Regarding File Transfer!
    FILE TRANSFER (4)
    Hi friends, I am looking for a secure and robust file transfer web service. I am handling a sales
    force which is stationed at different locations and is frequently moving. They need to upload there
    activity reports frequently to our servers. So I am looking for an easy to use secure and robust
    file transfer web service which can be used by my sales force for their needs. Thanks & Warm
    Regards. ....
  15. Windows Ntfs Folder And File Compression. Good Or Bad?
    (6)
    I believe everyone in this forum knows what a file system means and that every windows user knows
    what FAT and NTFS means so I am not gonna start going into those. Well, the NTFS (Windows NT file
    system) offers a few advantages over the good ol' FAT (File allocation table) file system one of
    which is the files and folders compression. This I have done quite a number of times to save disc
    space (and it really does save some disc space). i am using my computer as an example here. Consider
    my 35GB partition which is carrying my Windows Vista Operating sys and has less ....
  16. Hate Trying To Do File Sharing On Vista
    (2)
    i've had this attempt before with no luck now i'm going to try again! now that i got my
    two laptops (laptop1 - Vista, laptop2 - XP) wirelessly connected, i still can't see each
    others shared files... i tried this before with my PC (XP) and laptop (Vista) now i have to make
    this work because i have some files needed to be transfered between them... i have gone through
    the manual process of anabling file sharing blah blah through here
    http://www.microsoft.com/technet/network/e...e/vista_fp.mspx
    http://www.home-network-help.com/simple-file-sharin....
  17. Test Our New Free File Hosting! The Fastest In The World! Check It :)
    (12)
    Another freebie guys, and it certainly rocks! /smile.gif" style="vertical-align:middle"
    emoid=":)" border="0" alt="smile.gif" /> We launched the new Free File Hosting files-upload.com –
    check the speed! Take out anything you like, no limitation at all. http://files-upload.com ....
  18. Read File (.txt) On Another Website Using Jsp?
    (3)
    in my jsp program,i need to read a file (.txt) on another website,how can i do this? thanks a lot.
    shorten title ....
  19. A Trap17 How-to Guide For Beginners
    Something for those who can't get enough of the Trap17 Readme file (12)
    I am not entirely sure if this the right place to post about this, but here goes anyway... For
    those who find themselves slightly (or considerably more than slightly) clueless about where to get
    started after getting a hosting account, here is an user guide that might potentially help you
    out. I wrote it out of three hours, so forgive me if it's clumsy, but I'm hoping that a few
    people here may find it useful. Feedback is greatly appreciated /smile.gif"
    style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> I'm planning to build on
    a FAQ....
  20. How To Open A .daa File
    (37)
    Hi there, How do i have to open a file with extension .daa Somebody told me to copy it on cd and to
    run it from cd rom but i got the same problems. What dp i need to do to ppen the file? Thanks....
  21. Linux Question: Amarok And File Permissions
    please help, i can't get it to work with all music files (4)
    hey, i use to use Linux DC++ to download music from some hubs and i usually download it to
    /home/downloads/ and then i move the files to my collection on another HDD a sata one, on
    sda3/music/ but when i move the files using krushader root mode they become posessed by root and
    amarok can't play them displaying a locker on the file's icon. I tried to " chmod 774 music
    ", where music is my music directory, as root in konsole but no luck. What should i do to make a
    whole directory accessible from amarok as user?....
  22. How To Put Music In The Background Of A Powerpoint Presentation
    without having the viewer download the music file (9)
    Well, i made this power poit presentation in memory of my grandfather as many of you kno, passed
    away exactly a week ago....and i am trying to get this song to play as background music..and i did,
    but there is one humongus problem... in order for the people who are viewing it to hear the
    background music they have to download the music file as well ad the powerpoint presentation, which
    on my DSL conntection taked almost 2 minutes, and i could just imagine what it will be for a dial-up
    user (my grandma who wants to see it)... Some people may say, its impossible, but i kn....
  23. Simple C File Handling In Action
    Small code snipet which covers most of basic file handling and navigat (3)
    Yesterday I suddenly got a lot of work. The same work we try to push off, yes you are right all
    formalities to get the code review incorporated and update all source code files with code review
    headers. Imagine if you need to open 300 files one by one and append code review headers at the
    end. Since most files are reviewed in groups of 20 to 30 files. We require one header to be placed
    in say 20 to 30 files. To simplify I went back to my class assignment days and wrote this small c
    utility to open all files passed on command line and open attach code review headers an....
  24. Adding Rows & Columns In Html Table Using Javascript
    (1)
    I'm trying to create a website with a form that collects some user information to store in MySQL
    database. However, I've a problem when I want to dynamically add new rows and columns in the
    HTML table so that the user can add more information in the dynamically added textboxes. Here's
    what I have: CODE                  <table border="0" width="90%"
    align="center" id="itemsTable">                   <tr>
                       <td width="20%">                     Quantity                   
    <....
  25. How To: Make A Simple Php Site
    Making one file show up on all pages using php (21)
    I have looked all over the site and could not find anything that was like this simple, or just like
    this at all.. For some people i know that you are using a basic HTML site...and having a big menu
    if you want to add somthing you have to go into every one of the pages and add or remove or edit
    what you want to do, but with somthing verry simple all you would have to do is edit one file, and
    all of the pages that have the PHP script on them would suddenly change to what that one file is.
    So to start off if you are planning on using this little tirck, the page that you a....
  26. Transfer File Of Any Size Using Winsock Control
    Winsock Help (5)
    This tutorial shows how to transfer file of any size using winsock control. - Open VB; - Select
    standard exe; - Press Ctrl + t to show the add component window; - Select winsock control and
    microsoft common dialog; - Add one winsock control in the project; - Name it winsock1; - If you want
    to add chat then add another winsock and name it winsock2; - Insert another winsock object if you
    want to add chat also; - Add a microsoft common dialog box; - Name it cd; - We will use this
    winsock1 object to transfer the file and winsock2 for chat; ------------- The basic idea : ....
  27. Import From Excel File Into Mysql Database
    (7)
    Has anyone tried using the excel import function that comes with phpmyadmin
    http://www.phpmyadmin.net/home_page/ - it does not require any additional plug-ins or scripts and
    is fairly straightforward to use. In phpmyadmin, if you click on the database table which you wish
    to import the data to , there is a link on the bottom left corner which says "insert data from a
    text file into the table" - although it says text file it still can be used to import an excel file.
    When you click on this link you will be taken to a page where you will be asked for the file name
    (the....
  28. My File Manager Is Working
    (2)
    I tried to change the html for my site in file manager but it just has the default page - the one
    when you activate your site. /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' />
    How do i change files?....
  29. 500 Mb Free File Host!
    http://www.spread-it.com/ (18)
    Spread-It is a great, no nonsense file host. I've been looking extensively at free file hosts
    and most are up to 100 mb or something along those lines. The bigger ones for some reason are
    usually Japanese, but this a totally free, no registration file host for anything up to 500 mb. The
    only catch is that if it's not donwloaded once in 14 days it get's deleted. But other than
    that they claim it's hosted forever. http://www.spread-it.com/ ....
  30. Table/cell Link?
    (10)
    Well, I actually don't know what it is. But I need a code where you can click everywhere on the
    table, not only on the text/image.....

    1. Looking for alter, sql, table, php, file

Searching Video's for alter, sql, table, php, file
Similar
Internal
File
Transfer
Free
Software For
File
Recovery -
RECUVA
Where Is The
Bookmarks
File Stored
With Ff2?
Debug Exe
Files - How
to debug an
exe file.
Create Table
- Mysql Code
- Help
File Manager
Not Working
A Good File
Explorer For
Windows Xp?
- what's
a better
alternative
to explorer
Defraggler -
Free
Software To
Defrag Your
File - Try
it out
Qoodaa
Successfully
Solved Video
Downloading
Problems - a
good large
file
transfer
tool,
Share Qoodaa
- a good
large file
transfer
tool,
Issues
Uploading A
File
[resolved]
Make A
Moderately-s
ecure
Password
System Using
Javascript -
using file
redirection
to hide the
password.
Php
Configuratio
n File -
"config.
php"
Question
Regarding
File
Transfer!
; - FILE
TRANSFER
Windows Ntfs
Folder And
File
Compression.
Good Or Bad?
Hate Trying
To Do File
Sharing On
Vista
Test Our New
Free File
Hosting!
The Fastest
In The
World!
Check It :)
Read File
(.txt) On
Another
Website
Using Jsp?
A Trap17
How-to Guide
For
Beginners -
Something
for those
who
can't
get enough
of the
Trap17
Readme file
How To Open
A .daa File
Linux
Question:
Amarok And
File
Permissions
- please
help, i
can't
get it to
work with
all music
files
How To Put
Music In The
Background
Of A
Powerpoint
Presentation
- without
having the
viewer
download the
music file
Simple C
File
Handling In
Action -
Small code
snipet which
covers most
of basic
file
handling and
navigat
Adding Rows
&
Columns In
Html Table
Using
Javascript
How To: Make
A Simple Php
Site -
Making one
file show up
on all pages
using php
Transfer
File Of Any
Size Using
Winsock
Control -
Winsock Help
Import From
Excel File
Into Mysql
Database
My File
Manager Is
Working
500 Mb Free
File
Host! -
http://www.s
pread-it.com
/
Table/cell
Link?
advertisement



Alter Sql Table With Php File - how to?



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE