HTML specified for the submit button, php post prameter not passed - html

If a class is specified for the submit button, the post method parameter is not passed to php.
<form class = "delete_button", action="deleted.php" method="post">
<select name="nation" size=1>
<option value="KR">KR</option>
<option value="JP">JP</option>
<option value="US">US</option>
<option value="UK">UK</option>
<option value="GM">GM</option>
</select>
<input name = "email" type="email" placeholder="Enter your email">
<input class="delete_button_content" style="color:white" type="submit" value="delete">
</form>
and when I delete class for submit, it's working. what's problem ??

Related

HTML submit form from select but comma separate values in GET

I have a simple HTML form that has a dropdown.
<form method="get">
<select name="category[]" multiple class="form-control">
<option value="1">First Value</option>
<option value="2">Second Value</option>
<option value="2">Third Value</option>
</select>
<input type="submit" value="Submit">
</form>
Upon submission of this form, it redirects to https://WEBSITE/?category[]=1&category[]=2. How do I have it redirect to https://WEBSITE/?category=1,2
I was looking for a simple solution instead of using jQuery to intercept the form submission, load in every submitted value, comma separate it, and use window.location.href to redirect.
<select multiple class="form-control" onclick="document.getElementById('cat').value=Object.values(this.options).filter(option=>option.selected).map(option=>option.value).join(',')">
<option value="1">First Value</option>
<option value="2">Second Value</option>
<option value="3">Third Value</option>
</select>
<form method="get">
<input id="cat" type="hidden" name="category" value="">
<input type="submit" value="Submit">
</form>

Form with select tag

I have created a search box with select tag but : changes to &more%3A=abc when query is executed. I need to add more:abc or more:xyz when user choose from the select menu.
Is there any other workaround than jQuery?
<form action="test.html" id="searchform">
<input type="search" placeholder="Search here..."
name="q"/>
<input class="submit" type="image" src="icon.png">
<select name="more:" form="searchform">
<option value="">All</option>
<option value="abc">abc</option>
<option value="xyz">xyz</option>

perform action when button is clicked php

I'm trying to create a form using php in which the user will input some data, and I'll be able to store them in my database.
so far my code is this
<h1>Join Head Hunters <span class="colored-text">NOW</span>!</h1>
<form class="sform" method="get">
<input type="text" name="username" value="" placeholder="Username" method="get" maxlength="30">
<input type="password" name="password" value="" placeholder="Password" method="get" maxlength="30">
<input type="text" name="first_name" value="" placeholder="First name" method="get" maxlength="30">
<input type="text" name="last_name" value="" placeholder="Last name" method="get" maxlength="30">
<input type="text" name="address" value="" placeholder="Address" method="get" maxlength="80">
<input type="text" name="phone" value="" placeholder="Phone" method="get" maxlength="60">
<input type="text" name="mail" value="" placeholder="email" method="get" maxlength="40">
<input type="text" name="prof" value="" placeholder="Profession" method="get">
<input type="text" name="account" value="" placeholder="Bank Account" method="get">
<select multiple id="studies" class="specialColor" method="get">
<option value="highschool degree">Highschool Degree</option>
<option value="bachelors degree">Bachelors Degree</option>
<option value="MSc">MSc</option>
<option value="PhD">PhD</option>
<option value="MD">MD</option>
<option value="EdD">EdD</option>
<option value="JD">JD</option>
</select>
<select multiple="multiple" id="skillz" name="skillz[]" method="get">
<option value="administering programs">Administering Programs</option>
<option value="advising people">Advising people</option>
<option value="analyzing data">Analyzing data</option>
<option value="assembling apparatus">Assembling apparatus</option>
<option value="auditing financial reports">Auditing financial reports</option>
<option value="budgeting expenses">Budgeting expenses</option>
<option value="calculating numerical data">Calculating numerical data</option>
<option value="finding information">Finding information</option>
<option value="handling complaints">Handling complaints</option>
<option value="imagining new solutions">Imagining new solutions</option>
<option value="interpreting languages">Interpreting languages</option>
<option value="speaking to the public">Speaking to the public</option>
<option value="writing letters/papers/proposals">Writing letters/papers/proposals</option>
<option value="listening to others">Listening to others</option>
<option value="deciding uses of money">Deciding uses of money</option>
<option value="determining a problem">Determining a problem</option>
<option value="setting work/committee goals">Setting work/committee goals</option>
<option value="maintaining emotional control under stress">Maintaining emotional control under stress</option>
</select>
<select multiple="multiple" id="languages" name="languages[]" method="get">
<option value="english">English</option>
<option value="greek">Greek</option>
<option value="german">German</option>
<option value="japanese">Japanese</option>
<option value="spanish">Spanish</option>
<option value="italian">Italian</option>
<option value="french">French</option>
<option value="wookie">Wookie</option>
<option value="klingon">Klingon</option>
<option value="other">Other</option>
</select>
<input type="submit" class="button" name='create_account' value="Create Account"></input>
</form>
and the PHP for that:
<?php
$sservername = "localhost";
$susername = "root";
$spassword = "";
$sdbname = "projectDB";
mysql_connect($sservername, $susername, $spassword) or die("Cannot connect to server.");
mysql_select_db($sdbname) or die("Cannot select DataBase.");
if (isset($_POST["create_account"])) {
echo "<br><br><br><br><br>Button clicked";
//header("Location: signupsuccess.php");
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
//some error checking, now...
if (!preg_match($email_exp, $mail)) {
$error_message .= "<font color='red'>The Email address you entered does not appear to be valid.<br/></font>";
header("Refresh:0");
echo $error_message;
}
}
?>
Problem is that no matter how many times I try and press the button it never echos the "Button clicked" message and I can't figure out why!
Keep in mind, this is my first attempt on php and mysql. Any help? I've googled too much and I can't figure out my mistake.
<form class="sform" method="get">
if (isset($_POST["create_account"]))
A GET form will put the data in the query string, not the request body. $_POST won't be populated. Set the method to post.
Additionally, at present you are always going to output the Refresh 0 header, so it is quite likely that even if you did output the HTML then the page would refresh immediately and you wouldn't see it.

Form not submitting files

For some reason the following form isn't submitting the file like it should and I'm unsure why, on the server side if I check $_FILES it is always empty however if I check say $_POST['article'] that submit just fine, so only the file isn't being received then does anyone see something wrong with this?
<form action="newindex.php?do=submit" enctype="multipart/form-data" method="post">
Subject:<br>
<input type="text" id="subject" name="subject"><br>
<textarea id="article" id="article" name="article"></textarea><br>
<div class="sliderimage"><h2 class="blockhead">Slider Image:</h2>
<table><tr><td><b>Image:</b><br>Dimensions should be 640x360.</td><td>
<input type="file" id="image" name="image"></td></tr>
<tr><td><b>Transition:</b></td><td>
<select id="transition" name="transition">
<option value="">Random</option>
<option value="sliceDown">slideDown</option>
<option value="sliceDownLeft">sliceDownLeft</option>
<option value="sliceUp">sliceUp</option>
<option value="sliceUpLeft">sliceUpLeft</option>
<option value="fold">fold</option>
<option value="fade">fade</option>
<option value="slideInRight">slideInRight</option>
<option value="slideInLeft">slideInLeft</option>
<option value="boxRandom">boxRandom</option>
<option value="boxRain">boxRain</option>
<option value="boxRainReverse">boxRainReverse</option>
<option value="boxRainGrow">boxRainGrow</option>
<option value="boxRainGrowReverse">boxRainGrowReverse</option>
</select></td></tr>
<tr><td><b>Caption:</b></td><td>
<input type="text" id="caption" name="caption"></table><br></div>
<input type="hidden" name="securitytoken" value="<?php echo $vbulletin->userinfo['securitytoken'] ?>" />
<div class="center"><input type="button" value="Preview" class="preview"><input type="submit" name="submit"></div>
</form>
You need to have an input specifying the max file size:
http://www.php.net/manual/en/features.file-upload.post-method.php
put the size attribute in the and this will work.
<input id="image" name="image" type="file" size = '50'"/>

Using a HTML select element to add get parameters to URL

I'm on a page like /gallery.php?place=300&name=place1, and I want it so that when I submit this form it goes to /gallery.php?place=300&name=place1&tag=X, where X is the number of the tag selected.
What's wrong here?
<form action="/gallery.php?place=300&name=place1" method="get">
<select name="tag">
<option value=1>Aerial</option>
<option value=2>Autumn</option>
<option value=4>Boats</option>
<option value=6>Buildings</option>
<option value=7>Canals</option>
</select>
<input type="submit" value="Filter"/>
</form>
Use hidden inputs instead of trying to use the query string twice:
<form action="/gallery.php" method="get">
<select name="tag">
<option value=1>Aerial</option>
<option value=2>Autumn</option>
<option value=4>Boats</option>
<option value=6>Buildings</option>
<option value=7>Canals</option>
</select>
<input type="hidden" name="place" value="300" />
<input type="hidden" name="name" value="place1" />
<input type="submit" value="Filter" />
</form>
Using a form with method get was overwriting the query string in your form action.
This extra parameters seem to work for me locally when using "post" instead of "get." Is that it?