<?
if ($_POST['username'] == NULL){ //if nothing is entered or only a zero is entered
echo "Missing a field.";
}else{
//rest of code
}
This won't handle multiple textboxes I have 3: username, password, email
Try the below PHP code
<?
if ($_POST['username'] == NULL ||
$_POST['password'] == NULL ||
$_POST['email'] == NULL)
{ //if nothing is entered or only a zero is entered
echo "Missing a field.";
}else{
//rest of code
}
if(empty($_POST['memberfullname'])){
header("Location:srgbusinesspartnersmsg.php");
} else {
$insert= $con->command($ins);
header("Location:srgvalidatepartners.php");
}
This works for me. if it is empty , redirect a dialog form and else execute the job which is here an insert statement to be executed
Join us on Missionsoft Programming Institute (mtscertification.com)
Related
I am trying to set a cookie to my website, all steps are going well except when I check if the cookie isset, when I add this condition || isset($_COOKIE['username']) it undefines the index username in the next line, is there any mistake in the if statement?
if (isset($_SESSION['username']) || isset($_COOKIE['username'])) {
$userLoggedIn = $_SESSION['username'];
$user_details_query = mysqli_query($con, "SELECT * FROM users WHERE username='$userLoggedIn'");
$user = mysqli_fetch_array($user_details_query);
}
else {
$userLoggedIn = NULL;
}
I wish to abort the pipeline if the user did not select any value for Active Choice parameter for single/multi choice/string pipeline parameter.
For example I have Active Choices Reactive Parameter Named "IPAddress" of Type "Multi Select" with Groovy Script as below:
if (Location.equals("MyTown")) {
return["DDL1", "DDL2", "DDL3", "DDL4"]
} else if (Location.equals("Your Town")) {
return["DDP1", "DDP2"]
} else {
return ["Select an IP from the drop-down"]
}
Thus, once I run the pipeline i see "Select an IP from the drop-down" for IPAddress.
Now, If the user does not select anything from the dropdown the pipeline should fail & abort.
In the pipeline script I have written the below condition check which fails to check the condition despite user ignoring to select any IPAddress.
def ex(param){
currentBuild.result = 'ABORTED'
error('BAD PARAM: ' + param)
}
pipeline {
agent any
stages {
stage ("Pre-Check Parameters") {
steps {
echo "Pre-Check called in pipeline"
script {
if ("${params.IPAddress}" == null) {ex("IPAddress")}
//if ("${params.myEnv}" == null) {ex("b")}
//if ("${params.myLoc}" == null) {ex("c")}
}
}
}
}
}
Can you please suggest what could be the issue here ?
Do you have any constraint against using the input step?
def days=''
pipeline{
agent any;
stages {
stage('master'){
steps{
script {
try {
timeout(time:10, unit:'SECONDS') {
days = input message: 'Please enter the time window in number of days', ok: 'Fetch Statistics', parameters: [string(defaultValue: '90', description: 'Number of days', name: 'days', trim: true)]
}
}
catch (err){
error("No custom value has been entered for number of days.")
}
}
}
}
}
}
To determine if your string is empty you can use the method .trim(). It will remove leading and trailing spaces from your string. The two magic words are "Groovy Truth". An empty string is false in Groovy. This makes it easier to evaluate conditional expressions. Means in your case, if you use .trim() in combination with an if conditional then the Groovy Truth value of the string will be used for the evaluation.
Your pipeline should work if you change it to the following. It will check if your variable is null or empty:
script {
if (!params.IPAddress?.trim()) {
ex("IPAddress")
}
}
I am trying to validate a user typed email in Xamarin.Forms with Regex. For that I require that the pattern includes:
var emailPattern = #"^(?("")("".+?(?<!\\)""#)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])#))" +
#"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$";
Then I match the typed email with the pattern:
if (!Regex.IsMatch(Email, emailPattern) || Email == null)
{
EmailIsWrong = true;
}
else{
EmailIsWrong = false;
}
However, an error occurs, which is System.ArgumentNullException: Value cannot be null.
Parameter name: input on my if statement. I tried fixing it by having Email == null. This error occurs whenever I let the entry be empty.
For your problem, change the order of operands may help.
Like:
if (Email == null || !Regex.IsMatch(Email, emailPattern))
{
EmailIsWrong = true;
}
else{
EmailIsWrong = false;
}
If the first operand is satisfied, the second operand will be skipped
I have a input form and I want to check for some user_name properties. For instance if username is only lowercase with numbers. I am using callback function but given only a simple string such as "a" wont return true .. I really dont understand. What am I doing wrong ??
$this->form_validation->set_rules('user_name','User name','required|callback_validate_user_name');
...
if($this->form_validation->run() !== false){
$data['main_content'] = 'pages/news_page';
$this->load->view('templates/home_body_content', $data);
} else {
echo "Damn!";
}
function validate_user_name($user_name){
if(preg_match('/a/', $user_name) === true){
return true;
}
return false;
}
First, PHP preg_match() returns 1 if the pattern matches given subject [Reference]
So use === 1 or == TRUE instead of === true.
Second, callback function should return FALSE when /a/ pattern is occurred, and return TRUE if not.
When I press ENTER in Sitecore single line field textbox it renders TWO linebreaks
<br/><br/>
This issue appears only in Chrome/Firefox. In IE ENTER leads only to one
Can I disable somehow automatic adding of in these browsers?
Issue is caused by Sitecore Intranet.WebEdit.js
Modifiying this piece of code helped with problem:
if (evt.keyCode == 13 && this.activeElement && this.activeElement.contentEditable() && this.activeElement.parameters["linebreak"] == "br") {
try {
if (document.selection != null) {
var sel = document.selection.createRange();
sel.pasteHTML('<br />');
evt.stop();
}
if (!Prototype.Browser.IE) {
evt.srcElement.innerHTML = evt.srcElement.innerHTML + "<br/>";
evt.stop();
}
}