I want to know what is wrong with my code which was the question to Add a form to your php file that has a user put in a Username with the method post. If the name exists in the array, do nothing. If the name does not, add an element to the array with the Username and all other values set to 0. Print out the new array. (PHP)
$array=array(array('username' =>"joeDoe",'tweets'=> 2000,"Followers"=>45,"Following"=>8),
array('username' =>"JohnD", 'tweets'=>62000,"Followers"=>123,"Following"=>160),
array('username' =>"computerSavy",'tweets'=>75,"Followers"=>1,"Following"=>25),
array('username' =>"myTwitterAccount",'tweets'=>1800,"Followers"=>15,"Following"=>6));
echo "
Add New name
";
echo "
" ;
echo "";
echo "
" ;
if (isset($_POST['x']))
{
$new=$_POST['x'];
$check=false;
foreach($array as $key=> $value)
{
if($value['username']==$new )
{
$check=false;
break;
}
if(!$check)
$array=array('username'=>$new, 'tweets'=>0, 'Followers'=>0,'Following'=>0);
}
echo "";
foreach($array as $key =>$value)
{
echo "
";
}
echo"
| Handle(Username) | Tweets | Number of Follwers | Following |
|---|---|---|---|
| ".$value['username']." | ".$value['tweets']." | ".$value['Followers']." | ".$value["Following"]." |
";
}
please check out the code with changes
<?
$array=array(array('username' =>"joeDoe",'tweets'=> 2000,"Followers"=>45,"Following"=>8),
array('username' =>"JohnD", 'tweets'=>62000,"Followers"=>123,"Following"=>160),
array('username' =>"computerSavy",'tweets'=>75,"Followers"=>1,"Following"=>25),
array('username' =>"myTwitterAccount",'tweets'=>1800,"Followers"=>15,"Following"=>6));
echo "Add New name";
echo "
" ;
echo "";
echo "
" ;
if (isset($_POST['x']))
{
$new=$_POST['x'];
$check=false;
foreach($array as $key=> $value)
{
if($value['username']==$new )
{
$check=true;
break;
}
if($check)
$array=array('username'=>$new, 'tweets'=>0, 'Followers'=>0,'Following'=>0);
}
echo "";
foreach($array as $key =>$value)
{
echo "
";
}
echo"
Handle(Username) Tweets Number of Follwers Following
".$value['username']." ".$value['tweets']." ".$value['Followers']." ".$value["Following"]."
";
}
?>
I want to know what is wrong with my code which was the question to Add...
1. Print out information of PHP use phpinfo() function. 2. Write a program that check and print odd / even numbers (from number 1 to 100 using for/while loop). Display the results within an HTML table with 2 columns as shown below: NUMBERS RESULTS 1 ODD 2 EVEN 3 ODD HINT: use <table> tags to create a table, <th> tags for ‘Numbers’ and ‘Results’. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> <?php...
How can I print the Database table in PHP please ? here I have form for name and email, also I have php code that allow user to add his name and email to my database, all I need to print my final database when the user click on submit. <form action="" method="post"> <label>Name :</label> <input type="text" name="name" required="required" placeholder="Please Enter Name"/><br /><br /> <label>Email :</label> <input type="email" name="email" required="required" /><br/><br /> <input type="submit" value=" Submit " name="submit"/><br /> </form>...
PHP - Use of classes This is a further development of the previous task, the participant registration. You must use the following Participant class. <?php class Deltaker { private $etterNavn; private $forNavn; private $fAar; function __construct(string $fornavn, string $etternavn, string $aar) { $this->forNavn = $fornavn; $this->etterNavn = $etternavn; $this->fAar = $aar; } function hentEtterNavn() : string { return $this->etterNavn; } function hentForNavn() : string { return $this->forNavn; } function hentFAar() : string{ return $this->fAar; } //Setters function settForNavn(string $fornavn) {...
I need help showing the first column of the table to show up exactly with the mysql table into the php page. Is there a way to fix it ? So I created a php form where the user enters the information. sand.truman.edu/~jyl6557/assignment5/hw5-dataentry.php . it asks for name, hometown, gender(only male and female) and status (freshman, sophmore, junior, senior). once it checks and passes through those tests, it would say added successfully and then show the links to add another...
I need help please to add function for clean up any inputs form that we receive from the users for this code below : <?php session_start(); // initializing variables $fname = ""; $lname = ""; $address = ""; $city = ""; $state = ""; $zip = ""; $email = ""; $phone = ""; $errors = array(); // connect to the database $db = mysqli_connect("localhost","root","password","db"); // REGISTER USER if (isset($_POST['reg_user1'])) { // receive all input values from the form $fname =...
I am creating an Android application that has a login/registration page. To be able to use the application, the user must be 21 + years old. I have previously created php files for login, register, and update user info. I am having trouble on where to add code that will check if the user is 21+ into the update_user_info.php file I have created. I have figured out the correct mysql command to add to the php file, I am just...
For this code below, I need to add the form information to mysql when I click on submit, at the same time when I click on submit I need to move to another page like Welcome.php WITH NOTE THAT THE ENTERED INFORMATION NOW ALREADY IN DATABASE how can I male that with my code below? THANKS ................................................................................................................................................ <form method="POST"> <div class="container"> <label for="fname"><b>First Name</b></label> <input type="text" placeholder="Enter First Name" name="fname" required> <label for="lname"><b>Last Name</b></label> <input type="text" placeholder="Enter Last Name"...
PHP
Can't get my code to work, what am I doing wrong?
<!DOCTYPE html>
<html>
<head>
<script>
</script>
</head>
<body>
<h2>Temperature Conversion Table</h2>
<h4>Enter a starting value in degrees Fahrenheit and an
increment value.</h4>
<form name="myTemp"
onsubmit="convertCelcius()" method="post">
<input type="text" name="temperature"> Enter an value in
degrees Fahrenheit<br><br>
<input type="radio" name="degIncrement" id="degIncrement5">
Convert in increment in 5 degrees<br>
<input type="radio" name="degIncrement" id="degIncrement10">
Convert in increment in 10 degrees
<br/><br/><input type="submit"
value="Submit">
</form>
<?php
if( $_POST["temperature"] || $_POST["degincrement"] ) {
//get he...
Q1. rewrite the exercise on April 4 by adding the
following operations:
1) In the php script, create an associative array named
$order that stores the following values:
- the number of cheese toppings;
- the number of pepperoni toppings;
- the number of
ham
toppings;
- the size of the ordered pizza;
- the number of the ordered pizza;
- the total cost of the order;
- the discount rate;
- the total cost after the discount.
2) the...
My 2nd Try asking the same "PHP Programming with MySQL question. When I run my code, I get the following messages: Notice: Undefined index: email in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Notice: Undefined index: password in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 71 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /Applications/XAMPP/xamppfiles/htdocs/Week9/VerifyLogin.php on line 75 The e-mail address/password combination entered is not valid. Please use your browser's BACK button to return to the form and fix the errors indicated. Please use...