PHP file is not doing anything with String URL










1















I'm still very new to ajax and jquery, so sorry for the title, I didn't know how to phrase my question.



I'm having a problem with my URL string send: I have a Form set up which allows users to enter currency details as seen below, once the submit button has be pressed i want the data to be sent to a PHP file while having the page not redirect and putting what was sent in the text area below as XML.



I have the JQuery sending the string(to much data i dont want the operation or the textarea to be sent), but the PHP file is not doing anything with the data



Here's my code and my screenshots:

The Form:



 <form name="myform" id="myform" method="get">

<input type="radio" name="operation" value="1" id="Post"
onclick="displayFunctionPost()"> Post
<input type="radio" name="operation" value="2" id="Put"
onclick="displayFunctionPut()"> Put
<input type="radio" name="operation" value="3" id="Delete"
onclick="displayFunctionDelete()"> Delete
<br>
Currency Code:
<br>

<input type="text" name="currencycode" id="currencycode"
placeholder="Code" disabled>
<!--currency form-->
<br>
Currency Name
<br>
<input type="text" name= "currencyname" id="currencyname"
placeholder="name" disabled>
<br>
<!---rates form--->
Rate(£=1):
<br>
<input type="number" name="rate" id="rate" placeholder="rate" disabled>
<!---countries form-->
<br>
Countries (comma separated if 1+)
<br>
<input type="text" name= "countries" id="countries" placeholder="countries" disabled>
<br>

<!---xml response--->
<br>
Response Message:
<br>
<div id="textarea"><textarea id="textarea" cols="70" rows="5"></textarea>
</div>

<input type="Submit" name="Submit" id="Submit" value="Submit" >

</form>


And here is the JQuery I have so far:



 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>
$(document).ready(function()

$("#Submit").click(function(e)
e.preventDefault()
var data = "&currencyname="+currencyname+"&currencycode="+currencycode+"&rate="+rate+"&countries=";
var data = $('#myform').serialize();


$.ajax(
type: 'get',
cache: false,
url: 'currPut.php',
data: data,
processData: false,
contentType: false,
success: function( data )
alert('test ');


);

);
);
</script>


And here's the PHP file:



 <?php


@date_default_timezone_set("GMT");
$xml=new DomDocument("1.0","UTF-8");
$xml->formatOutput=true;
$xml->preserveWhiteSpace=false;
$xml->load('rates.xml');

if(!$xml)

$currencies=$xml->createElement("currencies");
$xml->appendChild($currencies);

else

$currencies=$xml->firstChild;


if (isset($_GET['Submit']))

$curcode = $_GET['currency-code'];
$newrate = $_GET['rate'];
$cname = $_GET['currency-name'];
$countries = $_GET['countries'];
$today = date("F j,g:i a");

$curr=$xml->createElement("currency");
$currencies->appendChild($curr);


$currate=$xml->createElement("code",$curcode);
$curr->appendChild($currate);
$currate->setAttribute("rate",$newrate);


$name=$xml->createElement("cname",$cname);
$curr->appendChild($name);

$places=$xml->createElement("cntry",$countries);
$curr->appendChild($places);


$xml->save('rates.xml');





?>


This is the form.



And this is the console.










share|improve this question
























  • This is either a client-side problem, or a server-side problem. Figure out which it is, and then remove the irrelevant tags and code from your question. Use your browser's inspector. Does the request get sent as expected? Is the response as expected?

    – miken32
    Nov 15 '18 at 0:11











  • You have name="currencycode" but $_GET['currency-code']. They don't match because of the hyphen difference.

    – Barmar
    Nov 15 '18 at 0:19











  • And the same thing for currencyname.

    – Barmar
    Nov 15 '18 at 0:19











  • thanks for the quick responses i will try these out!

    – Mrtcupz
    Nov 15 '18 at 0:21















1















I'm still very new to ajax and jquery, so sorry for the title, I didn't know how to phrase my question.



I'm having a problem with my URL string send: I have a Form set up which allows users to enter currency details as seen below, once the submit button has be pressed i want the data to be sent to a PHP file while having the page not redirect and putting what was sent in the text area below as XML.



I have the JQuery sending the string(to much data i dont want the operation or the textarea to be sent), but the PHP file is not doing anything with the data



Here's my code and my screenshots:

The Form:



 <form name="myform" id="myform" method="get">

<input type="radio" name="operation" value="1" id="Post"
onclick="displayFunctionPost()"> Post
<input type="radio" name="operation" value="2" id="Put"
onclick="displayFunctionPut()"> Put
<input type="radio" name="operation" value="3" id="Delete"
onclick="displayFunctionDelete()"> Delete
<br>
Currency Code:
<br>

<input type="text" name="currencycode" id="currencycode"
placeholder="Code" disabled>
<!--currency form-->
<br>
Currency Name
<br>
<input type="text" name= "currencyname" id="currencyname"
placeholder="name" disabled>
<br>
<!---rates form--->
Rate(£=1):
<br>
<input type="number" name="rate" id="rate" placeholder="rate" disabled>
<!---countries form-->
<br>
Countries (comma separated if 1+)
<br>
<input type="text" name= "countries" id="countries" placeholder="countries" disabled>
<br>

<!---xml response--->
<br>
Response Message:
<br>
<div id="textarea"><textarea id="textarea" cols="70" rows="5"></textarea>
</div>

<input type="Submit" name="Submit" id="Submit" value="Submit" >

</form>


And here is the JQuery I have so far:



 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>
$(document).ready(function()

$("#Submit").click(function(e)
e.preventDefault()
var data = "&currencyname="+currencyname+"&currencycode="+currencycode+"&rate="+rate+"&countries=";
var data = $('#myform').serialize();


$.ajax(
type: 'get',
cache: false,
url: 'currPut.php',
data: data,
processData: false,
contentType: false,
success: function( data )
alert('test ');


);

);
);
</script>


And here's the PHP file:



 <?php


@date_default_timezone_set("GMT");
$xml=new DomDocument("1.0","UTF-8");
$xml->formatOutput=true;
$xml->preserveWhiteSpace=false;
$xml->load('rates.xml');

if(!$xml)

$currencies=$xml->createElement("currencies");
$xml->appendChild($currencies);

else

$currencies=$xml->firstChild;


if (isset($_GET['Submit']))

$curcode = $_GET['currency-code'];
$newrate = $_GET['rate'];
$cname = $_GET['currency-name'];
$countries = $_GET['countries'];
$today = date("F j,g:i a");

$curr=$xml->createElement("currency");
$currencies->appendChild($curr);


$currate=$xml->createElement("code",$curcode);
$curr->appendChild($currate);
$currate->setAttribute("rate",$newrate);


$name=$xml->createElement("cname",$cname);
$curr->appendChild($name);

$places=$xml->createElement("cntry",$countries);
$curr->appendChild($places);


$xml->save('rates.xml');





?>


This is the form.



And this is the console.










share|improve this question
























  • This is either a client-side problem, or a server-side problem. Figure out which it is, and then remove the irrelevant tags and code from your question. Use your browser's inspector. Does the request get sent as expected? Is the response as expected?

    – miken32
    Nov 15 '18 at 0:11











  • You have name="currencycode" but $_GET['currency-code']. They don't match because of the hyphen difference.

    – Barmar
    Nov 15 '18 at 0:19











  • And the same thing for currencyname.

    – Barmar
    Nov 15 '18 at 0:19











  • thanks for the quick responses i will try these out!

    – Mrtcupz
    Nov 15 '18 at 0:21













1












1








1


1






I'm still very new to ajax and jquery, so sorry for the title, I didn't know how to phrase my question.



I'm having a problem with my URL string send: I have a Form set up which allows users to enter currency details as seen below, once the submit button has be pressed i want the data to be sent to a PHP file while having the page not redirect and putting what was sent in the text area below as XML.



I have the JQuery sending the string(to much data i dont want the operation or the textarea to be sent), but the PHP file is not doing anything with the data



Here's my code and my screenshots:

The Form:



 <form name="myform" id="myform" method="get">

<input type="radio" name="operation" value="1" id="Post"
onclick="displayFunctionPost()"> Post
<input type="radio" name="operation" value="2" id="Put"
onclick="displayFunctionPut()"> Put
<input type="radio" name="operation" value="3" id="Delete"
onclick="displayFunctionDelete()"> Delete
<br>
Currency Code:
<br>

<input type="text" name="currencycode" id="currencycode"
placeholder="Code" disabled>
<!--currency form-->
<br>
Currency Name
<br>
<input type="text" name= "currencyname" id="currencyname"
placeholder="name" disabled>
<br>
<!---rates form--->
Rate(£=1):
<br>
<input type="number" name="rate" id="rate" placeholder="rate" disabled>
<!---countries form-->
<br>
Countries (comma separated if 1+)
<br>
<input type="text" name= "countries" id="countries" placeholder="countries" disabled>
<br>

<!---xml response--->
<br>
Response Message:
<br>
<div id="textarea"><textarea id="textarea" cols="70" rows="5"></textarea>
</div>

<input type="Submit" name="Submit" id="Submit" value="Submit" >

</form>


And here is the JQuery I have so far:



 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>
$(document).ready(function()

$("#Submit").click(function(e)
e.preventDefault()
var data = "&currencyname="+currencyname+"&currencycode="+currencycode+"&rate="+rate+"&countries=";
var data = $('#myform').serialize();


$.ajax(
type: 'get',
cache: false,
url: 'currPut.php',
data: data,
processData: false,
contentType: false,
success: function( data )
alert('test ');


);

);
);
</script>


And here's the PHP file:



 <?php


@date_default_timezone_set("GMT");
$xml=new DomDocument("1.0","UTF-8");
$xml->formatOutput=true;
$xml->preserveWhiteSpace=false;
$xml->load('rates.xml');

if(!$xml)

$currencies=$xml->createElement("currencies");
$xml->appendChild($currencies);

else

$currencies=$xml->firstChild;


if (isset($_GET['Submit']))

$curcode = $_GET['currency-code'];
$newrate = $_GET['rate'];
$cname = $_GET['currency-name'];
$countries = $_GET['countries'];
$today = date("F j,g:i a");

$curr=$xml->createElement("currency");
$currencies->appendChild($curr);


$currate=$xml->createElement("code",$curcode);
$curr->appendChild($currate);
$currate->setAttribute("rate",$newrate);


$name=$xml->createElement("cname",$cname);
$curr->appendChild($name);

$places=$xml->createElement("cntry",$countries);
$curr->appendChild($places);


$xml->save('rates.xml');





?>


This is the form.



And this is the console.










share|improve this question
















I'm still very new to ajax and jquery, so sorry for the title, I didn't know how to phrase my question.



I'm having a problem with my URL string send: I have a Form set up which allows users to enter currency details as seen below, once the submit button has be pressed i want the data to be sent to a PHP file while having the page not redirect and putting what was sent in the text area below as XML.



I have the JQuery sending the string(to much data i dont want the operation or the textarea to be sent), but the PHP file is not doing anything with the data



Here's my code and my screenshots:

The Form:



 <form name="myform" id="myform" method="get">

<input type="radio" name="operation" value="1" id="Post"
onclick="displayFunctionPost()"> Post
<input type="radio" name="operation" value="2" id="Put"
onclick="displayFunctionPut()"> Put
<input type="radio" name="operation" value="3" id="Delete"
onclick="displayFunctionDelete()"> Delete
<br>
Currency Code:
<br>

<input type="text" name="currencycode" id="currencycode"
placeholder="Code" disabled>
<!--currency form-->
<br>
Currency Name
<br>
<input type="text" name= "currencyname" id="currencyname"
placeholder="name" disabled>
<br>
<!---rates form--->
Rate(£=1):
<br>
<input type="number" name="rate" id="rate" placeholder="rate" disabled>
<!---countries form-->
<br>
Countries (comma separated if 1+)
<br>
<input type="text" name= "countries" id="countries" placeholder="countries" disabled>
<br>

<!---xml response--->
<br>
Response Message:
<br>
<div id="textarea"><textarea id="textarea" cols="70" rows="5"></textarea>
</div>

<input type="Submit" name="Submit" id="Submit" value="Submit" >

</form>


And here is the JQuery I have so far:



 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script>
$(document).ready(function()

$("#Submit").click(function(e)
e.preventDefault()
var data = "&currencyname="+currencyname+"&currencycode="+currencycode+"&rate="+rate+"&countries=";
var data = $('#myform').serialize();


$.ajax(
type: 'get',
cache: false,
url: 'currPut.php',
data: data,
processData: false,
contentType: false,
success: function( data )
alert('test ');


);

);
);
</script>


And here's the PHP file:



 <?php


@date_default_timezone_set("GMT");
$xml=new DomDocument("1.0","UTF-8");
$xml->formatOutput=true;
$xml->preserveWhiteSpace=false;
$xml->load('rates.xml');

if(!$xml)

$currencies=$xml->createElement("currencies");
$xml->appendChild($currencies);

else

$currencies=$xml->firstChild;


if (isset($_GET['Submit']))

$curcode = $_GET['currency-code'];
$newrate = $_GET['rate'];
$cname = $_GET['currency-name'];
$countries = $_GET['countries'];
$today = date("F j,g:i a");

$curr=$xml->createElement("currency");
$currencies->appendChild($curr);


$currate=$xml->createElement("code",$curcode);
$curr->appendChild($currate);
$currate->setAttribute("rate",$newrate);


$name=$xml->createElement("cname",$cname);
$curr->appendChild($name);

$places=$xml->createElement("cntry",$countries);
$curr->appendChild($places);


$xml->save('rates.xml');





?>


This is the form.



And this is the console.







javascript php jquery xml






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 0:07









zx485

14.7k133047




14.7k133047










asked Nov 15 '18 at 0:02









MrtcupzMrtcupz

84




84












  • This is either a client-side problem, or a server-side problem. Figure out which it is, and then remove the irrelevant tags and code from your question. Use your browser's inspector. Does the request get sent as expected? Is the response as expected?

    – miken32
    Nov 15 '18 at 0:11











  • You have name="currencycode" but $_GET['currency-code']. They don't match because of the hyphen difference.

    – Barmar
    Nov 15 '18 at 0:19











  • And the same thing for currencyname.

    – Barmar
    Nov 15 '18 at 0:19











  • thanks for the quick responses i will try these out!

    – Mrtcupz
    Nov 15 '18 at 0:21

















  • This is either a client-side problem, or a server-side problem. Figure out which it is, and then remove the irrelevant tags and code from your question. Use your browser's inspector. Does the request get sent as expected? Is the response as expected?

    – miken32
    Nov 15 '18 at 0:11











  • You have name="currencycode" but $_GET['currency-code']. They don't match because of the hyphen difference.

    – Barmar
    Nov 15 '18 at 0:19











  • And the same thing for currencyname.

    – Barmar
    Nov 15 '18 at 0:19











  • thanks for the quick responses i will try these out!

    – Mrtcupz
    Nov 15 '18 at 0:21
















This is either a client-side problem, or a server-side problem. Figure out which it is, and then remove the irrelevant tags and code from your question. Use your browser's inspector. Does the request get sent as expected? Is the response as expected?

– miken32
Nov 15 '18 at 0:11





This is either a client-side problem, or a server-side problem. Figure out which it is, and then remove the irrelevant tags and code from your question. Use your browser's inspector. Does the request get sent as expected? Is the response as expected?

– miken32
Nov 15 '18 at 0:11













You have name="currencycode" but $_GET['currency-code']. They don't match because of the hyphen difference.

– Barmar
Nov 15 '18 at 0:19





You have name="currencycode" but $_GET['currency-code']. They don't match because of the hyphen difference.

– Barmar
Nov 15 '18 at 0:19













And the same thing for currencyname.

– Barmar
Nov 15 '18 at 0:19





And the same thing for currencyname.

– Barmar
Nov 15 '18 at 0:19













thanks for the quick responses i will try these out!

– Mrtcupz
Nov 15 '18 at 0:21





thanks for the quick responses i will try these out!

– Mrtcupz
Nov 15 '18 at 0:21












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310591%2fphp-file-is-not-doing-anything-with-string-url%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310591%2fphp-file-is-not-doing-anything-with-string-url%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3