473,378 Members | 1,522 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,378 software developers and data experts.

submit form without a "submit" button

i've been trying forever to figure out a way to use a regular text
link in place of a submit button at the bottom of this. can't get it.
i'm just starting to learn php, so i'm stuck. any help at all would be
amazing.
<?php # Script 12.7 - login.php
// This is the login page for the site.

// Include the configuration file for error management and such.
require_once ('includes/config.inc');

// Set the page title and include the HTML header.
$page_title = 'Login';
include ('includes/header.html');

if (isset($_POST['submit'])) { // Check if the form has been
submitted.

require_once ('../../mysql_connect.php'); // Connect to the database.

if (empty($_POST['username'])) { // Validate the username.
$u = FALSE;
echo '<p><font color="red" size="+1">You forgot to enter your
username!</font></p>';
} else {
$u = escape_data($_POST['username']);
}

if (empty($_POST['password'])) { // Validate the password.
$p = FALSE;
echo '<p><font color="red" size="+1">You forgot to enter your
password!</font></p>';
} else {
$p = escape_data($_POST['password']);
}

if ($u && $p) { // If everything's OK.

// Query the database.
$query = "SELECT user_id, first_name, last_name, username FROM users
WHERE username='$u' AND password=PASSWORD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_NUM);

if ($row) { // A match was made.

// Start the session, register the values & redirect.

$_SESSION['username'] = $row[3];
$_SESSION['first_name'] = $row[1];

$_SESSION['user_id'] = $row[0];

ob_end_clean(); // Delete the buffer.

header ("Location: http://" . $_SERVER['HTTP_HOST'] .
dirname($_SERVER['PHP_SELF']) . "/view_profile.php");
exit();

} else { // No match was made.
echo '<p><font color="red" size="+1">The username and password
entered do not match those on file.</font></p>';
}

mysql_close(); // Close the database connection.

} else { // If everything wasn't OK.
echo '<p><font color="red" size="+1">Please try again.</font></p>';
}

} // End of SUBMIT conditional.
?>
<div id="Content">
<h1>Login</h1>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="myForm"
method="post">

<p><b>User Name:</b><br> <input type="text" name="username" size="10"
maxlength="20" value="<?php if (isset($_POST['username'])) echo
$_POST['username']; ?>" /></p>
<p><b>Password:</b><br> <input type="password" name="password"
size="20" maxlength="20" /></p>
<div align="left"><input type="submit" name="submit" value="Login"
/></div>

</div>
</form><!-- End of Form -->
<?php // Include the HTML footer.
include ('includes/footer.html');
?>
Jul 17 '05 #1
5 12344
lsarg wrote:
i've been trying forever to figure out a way to use a regular text
link in place of a submit button at the bottom of this. can't get it.
i'm just starting to learn php, so i'm stuck. any help at all would be
amazing.


It's Javascript you're wanting not PHP.

<a href="javascript:document.formname.submit()">Link</a>

where "formname" is the name of your form eg <form name="formname">

Chris

--
Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/
Jul 17 '05 #2
"Chris Hope" <bl*******@electrictoolbox.com> schrieb im Newsbeitrag
news:40********@news.athenanews.com...
lsarg wrote:
i've been trying forever to figure out a way to use a regular text
link in place of a submit button at the bottom of this. can't get it.
i'm just starting to learn php, so i'm stuck. any help at all would be
amazing.


It's Javascript you're wanting not PHP.

<a href="javascript:document.formname.submit()">Link</a>

where "formname" is the name of your form eg <form name="formname">


But as Javascript might be turned off it is in most cases a good idea to
leave the submit button there though it does not look nice.

--
Markus
Jul 17 '05 #3
I noticed that Message-ID: <40***********************@news.easynet.ch>
from Markus Ernst contained the following:
But as Javascript might be turned off it is in most cases a good idea to
leave the submit button there though it does not look nice.


You can use an image. Even an image of some text.

--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #4
Markus Ernst wrote:
"Chris Hope" <bl*******@electrictoolbox.com> schrieb im Newsbeitrag
news:40********@news.athenanews.com...
lsarg wrote:
> i've been trying forever to figure out a way to use a regular text
> link in place of a submit button at the bottom of this. can't get it.
> i'm just starting to learn php, so i'm stuck. any help at all would be
> amazing.


It's Javascript you're wanting not PHP.

<a href="javascript:document.formname.submit()">Link</a>

where "formname" is the name of your form eg <form name="formname">


But as Javascript might be turned off it is in most cases a good idea to
leave the submit button there though it does not look nice.


I completely agree with that and should have mentioned it. You can also use
images as the submit or use styles to change the appearance.

Chris

--
Chris Hope
The Electric Toolbox Ltd
http://www.electrictoolbox.com/
Jul 17 '05 #5
> But as Javascript might be turned off it is in most cases a good idea to
leave the submit button there though it does not look nice.


Idea: leave the submit button and use javascript in the body onload
event to set style display to none. That way the button is only visible
if javascript is off.
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hal Halloway | last post by:
Given something like: if ( $_POST == 'Save record to HTGI public DB') { echo '<form method="post" action="populate08.php">'; echo '<input type=hidden name="kw_tarea" value='.$tk.'>'; echo...
1
by: jetmarc | last post by:
Hi. I hope that .javascript is the correct group for this question. I have a device with embedded webserver. Its page offers to reset the device, with the following javascript function: ...
8
by: EBG | last post by:
I have a simple email form on my site but getting screwy results because I know alot of users are hitting "enter" instead of tab when doing the form. When they hit enter the entire form is...
1
by: Dave | last post by:
Hi all, I was trying to make an image submit button with a rollover and discovered to my suprise that there is no way to access a form element of the "image" type. I tried specifying it by name...
3
by: Adam | last post by:
Hey guys, I've decided to stop banging my head against the wall and just ask you guys for the answer. I can't seem to find it. I have a form in which I have multiple submit buttons; only, I'm...
9
by: Prakash Singh Bhakuni | last post by:
am replacing the default "Browse..." button for input type=file. This works fine except that the form will only submit after the SUBMIT button is clicked twice. Any ideas on why this is happening...
4
by: raknin | last post by:
Hi, I have a list that I want every time the list is changed I want to change other elemnets in the form automatically without pressing any submit button, for example an update second list. All...
1
by: arggg | last post by:
I created a submit form that calls a javascript:AjAX Command that will call the data and submit it without have the page refresh. This works perfect in Firefox however in IE and Opera when the...
4
by: rotaryfreak | last post by:
so this has been blowing my mind for a few hours now and i have no idea what's going on. <form action="userLogin.php" method="get"> Username: <input type="text" name="userName" /><br/>...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.