nav33n 472 Purple hazed! Team Colleague Featured Poster

You should have your connection string before any sql operation. So, it would be like,

$connection=mysql_connect($host,$user,$pass);
if(!$conn) {
 echo "Error connecting.";
} else {
 echo "Connected.";
}

Instead of using if and else, you can use die function with mysql_error function to know the error in your mysql statement. die ends the execution of the script. (Its an alias of exit). $connection = mysql_connect($host,$user,$pass) or die(mysql_error()); :) Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

I don't think that is possible. If you have the access to the 'users' table, why don't you update the table setting an empty password ? Then send a mail to all the people in the users table(I am sure you will have a field 'email' in the table) asking them to create a new password for their username!

Edit: Welcome to Daniweb btw ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Fall of Rome is still a mystery for many !

nav33n 472 Purple hazed! Team Colleague Featured Poster

lol.. echo is used to output something to the screen :P . It should work in all browsers. http://localhost/filename.php should work fine in any browser. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

You are welcome! Check your php.ini (c:\php\php.ini or c:\wamp\apache2\bin\php.ini, if you are using Wamp) file for the line short_open_tag. If it is off, turn it On. If short open tags are turned off and if you have short open tags in your script, it will print the script. Thats why its always better to use <?php instead of <? !

And yep, You will learn in no time. Php is really easy ! :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hi ! welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

its pleasure to tell you guys that i've solved this problem. now i'm getting the table names from my sql database.

It would have been much more better if you had mentioned how you solved your problem. :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb alcont. You should have started a new thread :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. I am not sure about preg_replace. But you can do the same with str_replace!

<?php
$txt="' is a single quote \" is a double quote.I want to replace ' with \' and \" with \" ";
echo "Actual text: " .$txt."<br />";
$x=str_replace('"','\"',str_replace("'","\'",$txt));
echo "Replaced text: ". $x;
?>

Hope it helps!
Naveen

Venom Rush commented: Helpful as always ;) +1
nav33n 472 Purple hazed! Team Colleague Featured Poster

Have a hidden field to pass the number of textboxes. In the next page, use a for loop to get the values entered in those textboxes.

for($i=0;$<$number_of_textboxes;$i++){
 $txtboxname=$txt.$i;
$textbox_value=$_POST[$txtboxname];
print $textbox_value;
}

:)

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Hoy! Welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

You took a while to introduce yourself! welcome :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

hmm.. Its showing the query because you are printing it (echo $query; ). I don't see anything wrong with the query or the script. The problem might be with your php configuration.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. Get all the form information, align it as you want. Put it in the 'message' part of the mail.

nav33n 472 Purple hazed! Team Colleague Featured Poster

And I think he's still a virgin. =z

ROFLMAO! 40 year old virgin!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yep. You are wrong in writing the query.

<?
$host = "localhost";
$user = "myuser";
$pass = "mypassword";
$dbname = "voters";

$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."<BR>");
$dbname = "voters";
mysql_select_db($dbname);

$lname=$_POST['lname'];
$fname=$_POST['fname'];
$dob=$_POST['dob'];

$query= "select * from voters where lname='$lname' AND
fname='$fname' AND dob='$dob'"; 
echo $query;

$result= mysql_query($query);
$num_results = mysql_num_rows($result);

while ($row = mysql_fetch_array($result)) {
echo "<p>",$row['lname'], ": ",$row['fname'], ": ",$row['dob'];
}

?>

Check this. Don't you think this is much easier than using $_POST in your query ? I do it this way. I first assign the values of the $_POST to a php variable, then use that php variable(in this case, $fname,$lname and $dob). And, you shouldn't end your query (with a semicolon) after every condition.

nav33n 472 Purple hazed! Team Colleague Featured Poster

5=00000101

nav33n 472 Purple hazed! Team Colleague Featured Poster

3=00000011

nav33n 472 Purple hazed! Team Colleague Featured Poster

:( I only know binary !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Well, you can have a condition to check if the submit button was pressed.

if(isset($_POST['submit'])){
$message="This is the body of this mail. blah blah blah..........some more text... ";
mail("test@gmail.com","test mail",$message,"from: someone@gmail.com");
}

you can send all the data in the message part of the mail.

nav33n 472 Purple hazed! Team Colleague Featured Poster

You can use mail function.
Eg. mail("to address","subject","message contents","from: from address");

nav33n 472 Purple hazed! Team Colleague Featured Poster

y

:S Dude! is everything ok ? This is the 2nd time you are saying something which doesn't make any sense.

nav33n 472 Purple hazed! Team Colleague Featured Poster

MAN stands for Metropolitan Area Network.

nav33n 472 Purple hazed! Team Colleague Featured Poster

nav33n you noob. You have to copy first :P

Honestly though, just about anybody can change the world by being extremely dedicated to something that they are good at.

:twisted: You are right !

nav33n 472 Purple hazed! Team Colleague Featured Poster

World wide web is commonly know as www.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Book is a collection of pages.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome !

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

But how can I paste what's on my mind ?:S

nav33n 472 Purple hazed! Team Colleague Featured Poster

Time is precious! Dont waste it.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Say, for example, the user enters 10 in the first screen. On the next screen, you can do something like,

$textboxes_number=$_POST['number']; //the number of textboxes the user wants
$textboxes_number=10; //say user enters 10 in the previous screen
echo "<form name=form method=post action=somepage.php>";
for($i=0;$i<$textboxes_number;$i++){
echo "<input type='text' name=txt$i>";
}

echo "<input type='submit' name='submit' value='submit'>";
echo "</form>";

This will generate 10 textboxes with different names.

Cheers,
Naveen

nav33n 472 Purple hazed! Team Colleague Featured Poster

He's a 40 yr old monster. =s

:( Aww damn!

Sulley's Boo commented: told you, eww >_< +4
nav33n 472 Purple hazed! Team Colleague Featured Poster

Gay marriages are bizarre!

nav33n 472 Purple hazed! Team Colleague Featured Poster
CREATE TABLE test (
id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
name VARCHAR( 100 ) NOT NULL ,
address VARCHAR( 100 ) NOT NULL
) ENGINE = InnoDB

If that's my table, and I have a form with 2 fields name and address, this is how I would be inserting the values to the table test. This should get you started.(I hope!)

<?php
if(isset($_POST['submit'])){
$conn=mysql_connect("localhost","root");
mysql_select_db("exact");
$name=$_POST['name'];
$address=$_POST['address'];
$query="INSERT INTO TEST (ID,NAME,ADDRESS) VALUES ('','$name','$address')";
mysql_query($query);
}
?>
<html>
<body>
<form method="post" action="insert_example.php">
Enter Name: <input type="text" name="name"><br />
Enter Address: <textarea rows="10" cols="20" name="address"></textarea>
<br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

Cheers,
Nav

nav33n 472 Purple hazed! Team Colleague Featured Poster

I would validate on both client side and server side(because sometimes, the user might have disabled the javascript!)

nav33n 472 Purple hazed! Team Colleague Featured Poster

^
eww .. O_o
a perfect nightmare ..

Not if your boss is a sex bomb :P

nav33n 472 Purple hazed! Team Colleague Featured Poster

Change the world ? In what way ? Paste ? err..

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome to Daniweb!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome :)

nav33n 472 Purple hazed! Team Colleague Featured Poster

"Create a masterpiece", ordered Alexander.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Love is blind!

nav33n 472 Purple hazed! Team Colleague Featured Poster

Yes.

Do you think life exists on Mars ?

nav33n 472 Purple hazed! Team Colleague Featured Poster

Welcome!

nav33n 472 Purple hazed! Team Colleague Featured Poster

One of the main reason to use primary key is, because of its uniqueness. Say for example you have 4 columns in your table(name, age, city, country). If you don't have a primary key/unique id to differentiate between rows, your query may not do what you expect it to. Eg. Select * from user where name='name1' AND age='30'; might return several rows!
If you have a table with an auto_increment column (primary key/unique id) you can fetch the data (you want) using the unique id.

If you are inserting a record to a table with auto_increment field.
insert into table (id,name,age) values ('','name3','40'); You can access the last generated auto increment field (last inserted record's id) by using last_insert_id() or mysql_insert_id() .

If I am off topic, my apologies. (I didn't understand your question!)

nav33n 472 Purple hazed! Team Colleague Featured Poster

If you are using firefox, you can use Error console. Error console lists all the errors(javascript & css) encountered in your page.

nav33n 472 Purple hazed! Team Colleague Featured Poster

Umm.. Change “ ” to " ". Put data.txt in the same folder where you have the ajax script. I don't know much of ajax, but, the following code worked for me without any errors.

<html>
<head>
<title>Ajax at work</title>
<script language = "javascript">
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject) {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}
function getData(dataSource, divID)
{
if(XMLHttpRequestObject) {
var obj = document.getElementById(divID);
XMLHttpRequestObject.open("GET", dataSource);
XMLHttpRequestObject.onreadystatechange = function()
{
if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200 ) { 
	obj.innerHTML = XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.send(null);
}
}
</script>
</head>
<body>
<H1>Fetching data with Ajax</H1>
<form>
<input type = "button" value = "Display Message"
onclick = "javascript: getData('data.txt',
'targetDiv')">
</form>
<div id="targetDiv">
<p>The fetched data will go here.</p>
</div>
</body>
</html>

Cheers,
Naveen

Edit: SOS, you beat me by a minute :P

nav33n 472 Purple hazed! Team Colleague Featured Poster

Why don't you hire someone ? I even gave you the link to a function to generate random passwords. I can't write anymore scripts for you. Sorry.

nav33n 472 Purple hazed! Team Colleague Featured Poster

$row here is the recordset returned by the query, $query="select user_id from grads"; In this case, we are putting the values of user_id in a dropdown list.
To learn the basics of php and mysql, I would suggest you to visit this site.
Php is very easy to learn. Once you learn it, I am sure you can make your own login script.

dani190 commented: Great Job with help +1