473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

input/search databases

12
I’m learning the basics of database input/search using php. I’ve tried lot of examples from the web. My problem is that in all cases, the values supplied in the html form controls are not passed to the php page specified in the “action” statement. Need a help.
Oct 9 '06 #1
6 1620
ronverdonk
4,258 Expert 4TB
At least show your code (WITHIN code OR php TAGS!) so we all know what you are talking about.

Ronald :cool:
Oct 9 '06 #2
thavaht
12
Here is one of the examples a tried:
1. The conectdb.php page:


<?php
$hostname = "localhost";
$banco = "novateste";
$username = "root";
$senha = "ustm";
$dbconn = mysql_connect($hostname, $username, $senha);
mysql_select_db($banco, $dbconn);
?>

2. The html form page:

<html>
<head>
<title>Formul&aacute;rio para inserir no BD</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="inserindo.php" method="post" name="mural" id="mural">
<table width="450" border="0" cellspacing="0" cellpading="3">
<tr>
<td widht="111"><div align="right">Nome:</div></td>
<td widht="339"><input name="nome" type="text" id="nome" size="30"></td>
</tr>
<tr>
<td valign="top"><div align="right">Mensagem:</div></td>
<td><textarea name="mensagem" cols="30" rows="10" id="mensagem"></textarea></td>
</tr>
<tr>
<td height="29" colspan="2" valign="top"><div align="center">
<input type="submit" name="submit" value="Inserir no banco de dados">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>

3. The inserindo.php page:

<html>
<head>
<title>inserir no BD</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php require('conectdb.php'); ?>

<?php

$data = date('d-m-Y');
$hora = strftime("%H:%M:%S");
$sqlinsert = "INSERT INTO tb_mural (id_mensagem, nome, mensagem, data, hora)
VALUES ('','$nome', '$mensagem', '$data', '$hora')";

mysql_query($sqlinsert, $dbconn) or die("Nao foi possivel inserir");

echo "Na data $data e na hora $hora<br>$nome disse:<br>$mensagem";
?>
</body>
</html>

4. I fill the text and textarea and submit. Here is what I get in the returned page:

Na data 09-10-2006 e na hora 21:48:14
Disse:

5. I check the tb_mural, I find that fields “mensagem” and “nome” are empty; other fields have correct values.
Oct 9 '06 #3
ronverdonk
4,258 Expert 4TB
Why did you not, even after express request, show your code within code or php tags. I have no great urge to go thru that mess.

Anyway, you must pass your entered form data from the html script to the inserindo.php script, so in the latter you must pick them up via the $_POST array. That is what you don't do.

Ronald :cool:
Oct 9 '06 #4
thavaht
12
Definitely I’m really new in this matter. I never heard about code within code or php tags. Sorry.What is it about?
Oct 10 '06 #5
ronverdonk
4,258 Expert 4TB
Read the Posting Guidelines at the top of this forum. You are also shown the "Reply Guidelines" at the right side of the screen when you do a "Post reply".
Oct 10 '06 #6
thavaht
12
It’s all right now, thanks. Neither of the examples I tried makes reference to the $_POST array. That’s the right direction.
Oct 10 '06 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: WindAndWaves | last post by:
Hi Gurus I am keen to make a search page on a website, but I have absolutely zero experience with PHP. I am going to hire an expert, but I thought that it may pay to try it a bit first myself...
1
by: Nieuwsgroep | last post by:
Is it possible to open clipper databases and .ntx indexes ? Can I search etc. ?
6
by: Willem | last post by:
Hi, I have a newbie question: is it possible to make a search form in asp that searches in two different databases (access)? Willem
83
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd...
60
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't...
2
by: Merrall, Graeme | last post by:
I don't think there's an easy way to do this but I thought I better ask just in case. I'm trying to come up with a way to search across a number of databases without resorting to lots of horrible...
3
by: RoadRunner | last post by:
I have a form that has 6 command buttons on it. Each command button runs a different query with a wildcard parameter value that looks in 6 different tables in 6 different linked databases. None...
3
by: Henners | last post by:
Hi There We are migrating our network file system from Novell to Windows. (There are pros and cons).... In this process, we have noticed that a good bunch of user created access databases...
6
by: Omicron | last post by:
Hello, Can someone lead me in the right direct with this request: Please look at the piece of code below: <table summary="Sort Buttons"> <tr> <td> <input onclick="justSong_filter()"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.