/    Sign up×
Community /Pin to ProfileBookmark

Help- Script for php needed

HELP Please….

Hi.. Im a newbie in web design and almost Zero on php scripting. Cna any one help me or give me a simple script for my sample database?

My database has 5 fields : “ID” – key and VAR1, VAR2, VAR3, VAR4

What i want to do is :

>>>

Have a form field that would ask me to encode content of VAR1 <<<<
after i press submit
>>> New page or same page will ECHO me contents of VAR1 and VAR2
and also ask me to encode/input for VAR3…

>>>

If my input in VAR3 is correct (somewhat like password checking) The databse should show me the contents of VAR4…

Please if anyone can give me PHP script of this…

Please ask if you need clarifications…

-Shiela

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@miyaka_sheilaauthorFeb 06.2006 — I guess i'ts a little confusing, im not so good in english...

my design page looks like this:

Page1

__________________________________________

Please Enter Var1 : ___________ |SUBMIT|

__________________________________________

Page2

Do you "VAR1 CONTENT" in "VAR2 CONTENT"?

Ans : _______________________ |SUBMIT|


____________________________________________

echo " VAR1 | VAR2 | VAR3 | VAR4 ";
Copy linkTweet thisAlerts:
@miyaka_sheilaauthorFeb 07.2006 — SCRIPT STILL GOING NOWHERE
[code=php]
<br>

<?php

// Create a connection
$connection=mysql_connect("localhost","root","") or die ("Couldn't connect to server.");

// Select Database
$db = mysql_select_db("cris", $connection) or die ("Database Access Failed. Access Denied!");
$display = mysql_query("SELECT * FROM $TABLE ORDER BY VAR1",$connection);

if (!$submit){

echo "<form method=post action=$PHP_SELF>";
echo "<table border=0>";

// i want to know if im really connecting

while ($row = mysql_fetch_array($display))
{
$var1= $row["var1"];
$var2 = $row["VAR2"];
$var3 = $row["VAR3"];
$var4 = $row["VAR4"];

echo "<tr><td colspan=3>VAR1: <input type=text name=q$var1 value="$var1"> </td></tr>";
echo "<tr><td colspan=3>VAR2 : <input type=text name=q$var2 value="$var2"> </td></tr>";
}
echo "</table>";
echo "<input type='submit' name='submit'>";
echo "</form>";
}

elseif ($submit)

{
echo "<table border=0>";
$display = mysql_query("SELECT * FROM $table ORDER BY VAR1",$db);
while ($row = mysql_fetch_array($display)) {

echo "</table></p>";



}

?>[/code]
Copy linkTweet thisAlerts:
@SheldonFeb 07.2006 — Ok, I sat thre are read and read what you wrote, Then i wrote a script that would do what you want, Then when i when i went to post it i re-read your first post. Realising that what i had written maybe did not suit what you wanted.

Please clarify what you want.

Page 1).

form where you enter in your password($var1)? then submit

Page 2).

Echo $var1 if it matched $var2 (pulled from the database?)

form to enter second password($var3)?

Page 3).

echo $var1, $var2, $var3 and $var4 if $var3 == $var4 from the database?





Is that right? What are you trying to build? Or to achive?
Copy linkTweet thisAlerts:
@miyaka_sheilaauthorFeb 07.2006 — Thank you very much Sheldon...

Im very sorry for the confusion...

Ok... I have a clearer fields now... I tried to change the fields...

1st this is my present database...

____________________________________--


[CODE]

Table structure for table test1
----

CREATE TABLE test1 (
USER_KEY int(2) NOT NULL auto_increment,
USERNAME varchar(20) NOT NULL default '',
Reminder varchar(50) NOT NULL default '',
ReminderAns varchar(20) NOT NULL default '',
PASSWORD varchar(20) NOT NULL default '',
PRIMARY KEY (USER_KEY),
UNIQUE KEY USERNAME (USERNAME)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Test DB';

[/CODE]


from here... What i want to have is actually a simple password reminder...


Here are my scripts... None of them are working though...

first page:

[B]remind1.php[/B]

[CODE]
<?php
$connect = @mysql_connect('localhost','root','');
$selectdb = @mysql_select_db('testing',$connect);
$query = "SELECT USERNAME, Reminder, ReminderAns, FROM tbllogin_front ORDER BY USERNAME DESC";

$rs = mysql_query($query) or die('Error!');
$row = mysql_fetch_array($rs);

echo "FORGOT PASSWORD";
while ($row = mysql_fetch_array($rs))
{
$username = $row['USERNAME'];
$Reminder = $row['Reminder'];
$Ans = $row['ReminderAns'];

// just want to see whats happening
echo " $username, <br><p> $Reminder $ReminderAns ";
// am i connected?...

}
?>

<html>
<head><title>PASSWORD REMINDER</title></head>
<body bgcolor="#ffffff">
<table class="mainTable" style="border-collapse: collapse" width="512">

<tr align="center"><td colspan="2" align="center" bgcolor="#514EA5"></td></tr>
<p align="center">&nbsp;
<form method="post" action="remind2.php">
<table border="1" width="350" cellspacing="0" cellpadding="0" style="border-collapse: collapse">
<tr>
<td width="150">USER NAME: </td>
<td width="200"><input type="text" name="username" size="23"></td>
</tr>
<tr>
<td width="150"> [B]$Question Appers here whe username encoded [/B] </td>
<td width="200"><input type="text" name="ReminderAns" size="20"></td>
</tr>
<tr>
<td colspan="2">

<input type="submit" name="Submit" value="Submit">
<input type="reset" value="reset" name="reset">
</td>
</tr>
</table>
</form>
</table>

</body>

</html>
<?php>
@mysql_close($connect);
?>
[/CODE]



What i want is that on second page.. I will input the answer to the question.

second page:

I have this script and dunno if its working.

[B]remind2.php[/B]

[CODE]

<html>

<head>

<?php
$connect = @mysql_connect('localhost','root','');
$selectdb = @mysql_select_db('testing',$connect);

$query = "SELECT * FROM test1 WHERE USERNAME = '$username'";

$rs = mysql_query($query) or die('Error!');
$row = mysql_fetch_array($rs);
$username = $row['USERNAME'];

echo "FORGOT PASSWORD";
while ($row = mysql_fetch_array($rs)) {
$username = $row['USERNAME'];
$reminder = $row['Reminder'];
$Ans = $row['ReminderAns'];
$pass= $row['PASSWORD'];

echo " $username, <br><p> $Ans";
}
@mysql_close($connect);
?>

<TABLE>
<p align="center">&nbsp;
<form method="post" action="remind3.php">
<table border="1" width="350" cellspacing="0" cellpadding="0" style="border-collapse: collapse">
<tr>
<td width="150">ANSWER: </td>
<td width="200"><input type="text" name="password" size="20"></td>
</tr>
<tr>
<td colspan="2">
<?php
echo "<input type="hidden" name="username" value="$username">";
?>

<?php
echo "<input type="hidden" name="reminder" value="$reminder">";
?>
<input type="submit" name="Submit" value="Submit">
<input type="reset" value="reset" name="reset">
</td>
</tr>
</table>
</form>
<form>


</table>

</body>

</html>

[/CODE]


Then the last page would be able to retrieve my password or secret code...


[B]remind3.php[/B]

[CODE]

<?php

$username = isset($_GET['username']) ? $_GET['username'] : $_POST['username'];
$reminder = isset($_GET['reminder']) ? $_GET['reminder'] : $_POST['reminder'];
$Ans = isset($_GET['Ans']) ? $_GET['Ans'] : $_POST['Ans'];
$pass = isset($_GET['pass']) ? $_GET['pass'] : $_POST['pass'];

echo "username = $userid<br>
reminder = $reminder<br>
Ans = $Ans<br>";

$connect = @mysql_connect('localhost','root','');
$selectdb = @mysql_select_db('training',$connect);
$query = "SELECT * FROM test1
WHERE USERNAME='$username' AND $reminder='$reminder' AND $Ans='$Ans'";
echo "Your Password is $pass <br>";

?>


[/CODE]
Copy linkTweet thisAlerts:
@miyaka_sheilaauthorFeb 07.2006 — I think it would be also possible to execute this in one single page... But i dunno how to make it possible...

[B]How could I.. I cant even meke it work.. ?(
Copy linkTweet thisAlerts:
@miyaka_sheilaauthorFeb 07.2006 — Sheldon this is how the script "I hope" will work

Page1.

When user encodes username, scripts retrieves the stored Passworrd reminder question.

Page2

Displays Username and Question

Page3

Releases the Password for the user to view.

?

Hope its clearer now..

[B]Help.. Anyone.. [/B]
Copy linkTweet thisAlerts:
@miyaka_sheilaauthorFeb 08.2006 — any help for this please?
×

Success!

Help @miyaka_sheila spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...