Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I think I miss something about the verification of my PHP request. I'm actually doing $result = $req->fetch(); but result always return false for some reason.
$bdd = new PDO($conStr,$user,$pass);
$req = $bdd->prepare('INSERT INTO users(login, password, dateregister) VALUES(?, ?, NOW())');
$req->execute(array($loginR,$passwordR));
$result = $req->fetch();
Check the return value of execute function for success/failure message
$res = $req->execute(array($login_fieldR,$password_fieldR));
if (!$res )
{
echo '<p id="popup_text">Problem..</p>';
}
else
{
echo '<p id="popup_text">You are registered ! You can logged in now';
}
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am a newbie to php and trying to write the code that validates my form.now the problem is I am having trouble in this line of code:
$fullname_pattern = "/[a-zA-Z]+/";
$fullname = $_POST['fullname'];
$email = $_POST['email'];
$email_pattern = "/^[a-zA-Z]+([a-zA-Z0-9]+)?#[a-zA-Z]{3,50}\.(com|net|org)/";
$password = $_POST['password'];
$password_pattern = "/(.){6,12}/";
if(preg_match($fullname_pattern,$fullname)) &&
(preg_match($email_pattern,$email)) &&
(preg_match($password_pattern,$password))
{
header("Location: home.php");
}
else
header("Location: registration.php");
Don't know what to do!
if(preg_match($fullname_pattern,$fullname))
Remove Last ")"
And add here (preg_match($password_pattern,$password)))
Like this:
if(preg_match($fullname_pattern,$fullname)
&& preg_match($email_pattern,$email)
&& preg_match($password_pattern,$password)
) {
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Can anyone tell where am I wrong in the query. The database in not updating irrespective of the value
<?php
// ================= UPDATE =========================
if ($_POST['SUBMIT']=='SUBMIT')
{
$fixture_id = "$_GET[id]";
$m_date = "$_POST[match_date]";
$m_time = "$_POST[match_time]";
$m_report = "$_POST[match_report]";
$m_a_result = "$_POST[team_a_result]";
$m_b_result = "$_POST[team_b_result]";
$updt = mysql_query("UPDATE `fixture` SET match_date='$m_date', match_time='$m_time', match_report='$m_report', match_a_result='$m_a_result', match_b_result='$m_b_result', status = 1 WHERE id = '$fixture_id'");
header("location:view_fixture.php?msg= You have inserted result successfully...");
}
else
{
header("location:result_update.php?msg= Something went wrong...");
}
// ================================================================================
?>
Before executing this make sure your submit button have a string value of "SUBMIT"
Try this ..
<?php
$fixture_id = $_GET[id];
if ($_POST['SUBMIT']=='SUBMIT')
{
$m_date = $_POST['match_date'];
$m_time = $_POST['match_time'];
$m_report = $_POST['match_report'];
$m_a_result = $_POST['team_a_result'];
$m_b_result = $_POST['team_b_result'];
$updt = mysql_query("UPDATE `fixture` SET match_date= '$m_date', match_time='$m_time', match_report='$m_report', match_a_result='$m_a_result', match_b_result='$m_b_result', status = 1 WHERE id = '$fixture_id'");
header("location:view_fixture.php?msg= You have inserted result successfully...");
}
else
{
header("location:result_update.php?msg= Something went wrong...");
}
?>
Please DO NOT USE mysql_* . It is now deprecated
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
<?php if($_POST) {
$username = htmlspecialchars($_POST['username']);
$password = htmlspecialchars($_POST['password']);
$mysqli = new mysqli('localhost','root','','movie_posters');
$query = $mysqli->query("SELECT password FROM users WHERE username = '"$username"'");
} ?>
When I try this code on WAMP, I get error like; this http://i.stack.imgur.com/qcifR.jpg
What can I do ?
Do not use single and double quotes in your query.
This is the right way:
$query = $mysqli->query("SELECT password FROM users WHERE username = '$username'");
Otherwise, you will not print $username's value.
You have to put periods before and after you variable.
In your example:
$query = $mysqli->query("SELECT password FROM users WHERE username = '".$username."'");
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
Hello guys i don't know what is call if or switch statement.
i have database table field which is call price, so i want to make if the price if the price field empty its show "please Call us for the price " and if the price field is not its i will show what ever i put it..
here is my code but i don't know why its not working..
any body can help please
thanks you
<?php
$result = mysql_query("SELECT * FROM articles where articlefriendlyURL='%s'",mysql_real_escape_string($aid));
while($row = mysql_fetch_assoc($result)) {
if ($row['price']; = = '') {
echo ("Please Call Us for the price");
else {
echo $row_getArticle['price'];
}
}
}
?>
You can't separate the equals signs or its no longer a conditional statement to check the equal to. you also had a syntax error with your if/else from the brackets. Try this:
<?php
$result = mysql_query("SELECT * FROM articles where articlefriendlyURL='%s'",mysql_real_escape_string($aid));
while($row = mysql_fetch_assoc($result)) {
if (empty($row['price'])) {
echo ("Please Call Us for the price");
} else {
echo $row['price'];
}
}
?>
I think the problem is on
if ($row['price']; = = '0')
I think the correct syntax of that statement is
if ($row['price'] == '0')
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have to send an email, the email can be formatted and stored in database. But the problem is I have to use some variable in the email to make it a dynamic email for each user.
INSERT INTO email (greeting) VALUES ( "Hello $name");
$coding = mysql_query("SELECT * FROM email ") or die(mysql_error());
$email = mysql_fetch_array( $coding );
echo $email['greeting'];
it should echo Hello PERSONS_NAME; like Hello John, But it echo Hello $name, as it is..
Does not work, Any help ???
You will probably be better off using placeholders and then swap out the placeholder with dynamic text when sending the email:
INSERT INTO email (greeting) VALUES ( "Hello %%NAME%%");
$coding = mysql_query("SELECT * FROM email ") or die(mysql_error());
$email = mysql_fetch_array( $coding );
$email['greeting'] = str_replace('%%NAME%%', $name, $email['greeting']);
echo $email['greeting'];