The Most Active and Friendliest
Affiliate Marketing Community Online!

“Propeller”/  Direct Affiliate

Complete beginner - Does anyone want to answer my stupid questions?

StevieB

New Member
affiliate
Hi,
Thanks for reading. I'm a complete beginner and really nead some help. I'm trying to develop a brand new website but need help on the php/html/mysql side of things.

1'st stupid question ~
i want to collect customers' text input on a HTML screen and store it to put it into an output from a php script accesing a mysql database.

will

<h4>Input here</h4>
<form action="my website address" method="post">
<input type="text" name="color" id="color"/>
<input type="submit" value="Click"/>
</form>

work????

will this collect the text?
where does it store it?
can I do this with up to 4 different txt inputs at the same time?

thanks

Steve
 
Your form is okay. What you need to do is to create your database on what you will save the submitted data and also to point your form 'action' to a simple php script what connect to your database and insert on this the submitted data.

1. Your Form (for example send.html):
<h4>Input here</h4>
<form action="processing.php" method="post">
<input type="text" name="color" id="color"/>
<input type="text" name="size" id="size"/>
<input type="submit" value="Click"/>
</form>

2. The script (processing.php)
<?php
$hostname_example = "localhost";
$database_example = "your_database_name";
$username_example = "your_database_username";
$password_example = "your_database_password";
$example = mysql_pconnect($hostname_example, $username_example, $password_example) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_example, $example);
$result = mysql_query ("INSERT INTO your_database_table_name (color, size) VALUES('$color', '$size')");
?>
3. For the above example on the datbase you will need to crete one table and to add to this the below fields:
- color
- size
 
Hey thanks for that ;) , but I think I mislead, I don't want to permanently store the info, just hold it for a while, collect some text from the database and substitute the inputted text where HHHH and EEEE appear ~

a friend got me as far as this (then buggered off and i can't contact her)but it doesn't work and I can't seem to get it to work. What's wrong with the script cos it's got me stumped. :sCo_idk4: It did work locally on her PC (that's why I asked the first question cos I thought it might be something to do with the html.)

-----------------------------------------------------------------------

The database has text and also HHHH and EEEE in the places where I want to put the gathered text ~






<h4>Input here</h4>
<form action="address of website and name of php code" method="post">
<input type="text" name="color" id="color"/>
<input type="submit" value="Click"/>
</form>
</body>
<?php

// Connect to a MySQL server
$link = mysql_connect(
'hostname', // The host to connect to
'User', // The user to connect as
'password', //The password to use
'database'); // The default database to query
//If connection not made successfully show error message
if (!$link) {
printf("Can't connect to MySQL Server. Errorcode: %s\n", mysql_connect_error());
exit;
}
$query = 'SELECT * FROM table name ORDER BY RAND() LIMIT 1';
for($i = 0; $i <= 2; $i++){
// Send a query to the server
if ($result = mysql_query($link,$query)) {
// Fetch the results of the query
while( $row = mysql_fetch_row($result) ){
$row = str_replace('EEEE', 'HHHH', $row);
$joinedstr =$row[$i];
printf("%s", $row[$i]);
//printf("%s", $row[0]);
//printf("%s", $bodytag);
echo "</br>";
}
printf("%s", $joinedstr);
// Destroy the result set and free the memory used for it
mysql_free_result($result);
}
}
// Close the connection
mysql_close($link); */


// Connect to a MySQL server
$link = mysql_connect(
$host, // The host to connect to
$usr, // The user to connect as
$pw //The password to use
);
//If connection not made successfully show error message
if (!$link) {
printf("Can't connect to MySQL Server. Errorcode: %s\n", mysql_connect_error());
exit;
}
$db=mysql_select_db($db,$link)
or die ("Couldn't select database.");

$query = 'SELECT * FROM table name ORDER BY RAND() LIMIT 1';
//$color=$_POST['color'];
for($i = 0; $i <= 2; $i++){
// Send a query to the server
if ($result = mysql_query($query)) {
// Fetch the results of the query
while( $row = mysql_fetch_row($result) ){
//$row = str_replace('EEEE',$color , $row);
printf("%s", $row[$i]);
echo "</br></br></br>";
}

// Destroy the result set and free the memory used for it
mysql_free_result($result);
}
}
// Close the connection
mysql_close($link);
?>
</html>
 
banners
Back