473,734 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.p hp'); // 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($_P OST['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($_P OST['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=PASSWO RD('$p')";
$result = @mysql_query ($query);
$row = mysql_fetch_arr ay ($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($_SERVE R['PHP_SELF']) . "/view_profile.ph p");
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">Pleas e 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"><i nput 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 12408
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="javascrip t:document.form name.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*******@elec trictoolbox.com > schrieb im Newsbeitrag
news:40******** @news.athenanew s.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="javascrip t:document.form name.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************ ***********@new s.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*******@elec trictoolbox.com > schrieb im Newsbeitrag
news:40******** @news.athenanew s.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="javascrip t:document.form name.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
4065
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 '</form>'; echo '<p>permanent DB updated'; } But there's no button to press for a submit. So how do I get this code
1
2849
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: function Restart() {
8
2823
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 submitted whether it's finished or not. Is there an easy way to correct this? My site only cares about IE.
1
3050
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 and also by the elements array with no luck. Even weirder, I can sandwich an image button in between other input types and then write a script diplaying the contents of the elements array and it acts as if the image button does not exist at all!...
3
10148
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 using button tags, not input tags to do it. It seems that IE6 is treating all the button elements as being successful on submit. This is, to say the least, surprising since the Spec is pretty clear that it should.
9
24750
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 or a workaround? I'm testing on IE Thanks! <html> <head></head> <body> <form name="test_form" method="post" action="test.jsp">
4
2702
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 this will be done with PHP and Javascript. Is it possible?
1
2249
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 submit button is pressed it just disables the button and does not submit the data. Any idea? <script type="text/javascript" src="<?=$config->getKey('Site_URL')."js/AJAX.js"?>"></script> <form name="EditUser" method="post" accept="text/plain"...
4
7583
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/> Password: <input type="password" name="pwd" /><br/> <input type="submit" /> </form>
0
8946
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9310
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.