html input field issue - html

i'm new to html and this is probably a stupid mistake but i cant spot it. Whenever i select a input field, the cursor always jumps to the first input box. I'm guessing i missed an ending statement somewhere but i cant spot it...
<form method = "POST" action="changeCourse.php";>
<label for="newModule">Module:<label>
<input type="text" name="newModule" input value = "<?php echo $_REQUEST['modules'];?>"/>
<label for="newCode">Code:</label>
<input type="text" name="newCode" input value = "<?php echo $_REQUEST['codes'];?>"/>
<label for="newLesson">Lesson Type</label>
<select name="newLesson" id="newLesson">
<OPTION SELECTED><?php echo $_REQUEST['lesson_types'];?></option>
<option label="newLesson">Lecture</option>
<option label="newLesson">Tutorial</option>
</select>
<label for="newCredit">Credit:</label>
<input type="text" name="newCredit" input value = "<?php echo $_REQUEST['credits'];?>"/>
<label for="newLevel">Level</label>
<select name="newLevel" id="newLevel">
<OPTION SELECTED><?php echo $_REQUEST['levels'];?></option>
<option label="newLevel">4</option>
<option label="newLevel">5</option>
<option label="newLevel">6</option>
</select>
<label for="newCore">Core:</label>
<input type="text" name="newCore" input value = "<?php echo $_REQUEST['cores'];?>"/>
<label for="newLab">Lab Number:</label>
<input type="text" name="newLab" input value = "<?php echo $_REQUEST['labs'];?>"/>
<label for="facilities">Lab Facilities</label>
<select name="facilities" id="day">
<OPTION SELECTED><?php echo $_REQUEST['facilities'];?></option>>
<option label="facilities">Full(MS Office, Programming Packages, Adobe Packages)</option>
<option label="facilities">Partial(MS Office, Adobe Packages)</option>
<option label="facilities">Simple(MS Office)</option>
</select>
<label for="newTeacher">Teacher:</label>
<input type="text" name="newTeachers" input value = "<?php echo $_REQUEST['teachers'];?>"/>
<label for="newDay">Day</label>
<select name="newDay" id="day">
<OPTION SELECTED><?php echo $_REQUEST['days'];?></option>
<option label="newDay">Monday</option>
<option label="newDay">Tuesday</option>
<option label="newDay">Wednesday</option>
<option label="newDay">Thursday</option>
<option label="newDay">Friday</option>
</select>
<label for="newTime">Time:</label>
<input type="text" name="newTime" input value = "<?php echo $_REQUEST['times'];?>"/>
<label for="newComment">Additional Comments:</label>
<textarea style="resize: none;" cols="30" rows="3" name="newComment"> hello </textarea>
<input type="submit" value="Update Record" />
<input type="hidden" name="id" value="<?php echo $_REQUEST['ids'];?>">
</form>

Not sure if this is the reason but you have a bunch of input value's and it should only be value drop the input

First of all, you should fix your HTML. Open up your page in the browser, show the HTML source code and copy and paste it as direct input to an HTML validator. Fix all mentioned issues, and try again.
Do you still have the problem once your HTML is fixed?

Related

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.

Show second value from select option

I want show in input text from select option where in value have 2 data
function changeHiddenInput (objDropDown)
{
document.getElementById("hiddenInput").value = objDropDown.value;
}
<form name="ff">
<select id="dropdown" name="dropdown" onchange="changeHiddenInput(this)">
<option value="j.hotmail.com|3">Jens</option>
<option value="a.hotmail.com|4">Adam</option>
<option value="d.homtail.com|5">Dan</option>
</select>
<input type="text" type="hidden" name="hiddenInput" id="hiddenInput" />
</form>
I want get value 3,4,5 and show in input text form when each option select.
split your value using " | "
function changeHiddenInput (objDropDown)
{
document.getElementById("hiddenInput").value = objDropDown.value.split('|')[1];
}
<form name="ff">
<select id="dropdown" name="dropdown" onchange="changeHiddenInput(this)">
<option value="j.hotmail.com|3">Jens</option>
<option value="a.hotmail.com|4">Adam</option>
<option value="d.homtail.com|5">Dan</option>
</select>
<input type="text" type="hidden" name="hiddenInput" id="hiddenInput" />
</form>

HTTP GET isn't working?

I have a form on a webpage that will submit data in the fields to be processed on another page.
Here is the form:
<form align="center" action="submitrivalsconfig.php" method="get">
<b>PN Operator:</b>
<select name="PNOp" value="<?php echo $data["PNOp"]?>">
<option value="=">=</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
</select>
<b>PN Value: </b>
<input type="number" name="PNValue" value="<?php echo $data["PNValue"]?>" style="width:40px">
<br><br>
<b>MEL Operator:</b>
<select name="MELOp" value="<?php echo $data["MELOp"]?>">
<option value="=">=</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
</select>
<b>MEL Value:</b>
<input type="number" name="MELValue" value="<?php echo $data["MELValue"]?>" style="width:40px">
<br><br>
<b>NDZ Operator:</b>
<select name="NDZOp" value="<?php echo $data["NDZOp"]?>">
<option value="=">=</option>
<option value=">">></option>
<option value="<"><</option>
<option value=">=">>=</option>
<option value="<="><=</option>
</select>
<b>NDZ Value: </b>
<input type="number" name="NDZValue" value="<?php echo $data["NDZValue"]?>" style="width:40px">
<br><br>
<b>Fuel Type:</b>
<input type="text" name="FuelType" value="<?php echo $data["FuelType"]?>" style="width:400px">
<br><br>
<input type="submit" value="Submit Configuration">
</form>
Upon pressing the submit button, I am redirected to the following url:
bmratest/minipages/submitrivalsconfig.php?PNOp=%3D&PNValue=54&MELOp=%3D&MELValue=60&NDZOp=%3D&NDZValue=90&FuelType=%27CCGT%27%2C+%27COAL+IN%27%2C+%27COAL+OUT%27%2C+%27OCCGT%27%2C+%27OIL%27
Everything seems fine to me so far, but I assigned the data transferred to an array and it outputs blanks, suggesting that the $_GET details are blank and it isn't reading the information from the URL.
The superglobal you are looking for is called $_GET not $GET_.

"checked" and "selected" in HTML for input do not work with AngularJS

I am learning AngularJS and user input. In my code, I tried to set default state for drop down menu and radio button with "selected" and "checked".
However, they do not work together with "ng-model" attribute.
Also, for the first radio button (ascending), the empty value attribute seems to hinder with "checked" attribute.
Could anyone explain why this happens and how to bypass this problem?
<div class="search">
<h1>Artist Directory</h1>
<label> Search: </label>
<input ng-model="query" placeholder="Search for artists" autofocus>
<label class="formgroup">by:
<select ng-model="listOrder" name="direction">
<option value ="name" selected="selected"> Name</option>
<option value="reknown"> Reknown</option>
</select>
</label>
<label class="formgroup">
<input ng-model="direction" type="radio" value=" " checked> Ascending
</label>
<label class="formgroup">
<input ng-model="direction" type="radio" value="reverse"> Descending
</label>
</div>
tie your button and select to an ng-model. Default values are the values you put in the model when the scope is first created. Then values are updated when user clicks :
function test($scope) {
$scope.selected = ['1','3'];
$scope.checked = "green";
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<div ng-app>
<h2>Todo</h2>
<div ng-controller="test">
<select name="" ng-model="selected" multiple>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
<br><br>
<input type="radio" ng-model="checked" value="red"> Red <br/>
<input type="radio" ng-model="checked" value="green"> Green <br/>
<input type="radio" ng-model="checked" value="blue"> Blue <br/>
<br>
Selected : {{selected}}
<br>
Checked : {{checked}}
</div>
</div>
See it in action : http://jsfiddle.net/913n30zf/
Select in AngularJS looks likes this:
<select ng-model="selectedOpt"
ng-options="opt for opt in listOrder">
</select>
And back in the controller you set
$scope.selectedOpt = $scope.listOrder[0];
which option you want to be select by default.

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'"/>